How can I add python packages to the Leap IDE?

The Leap IDE comes pre-loaded with a wide variety of useful Python packages that you can use right away with your code. To see what packages are automatically installed, open the terminal in the IDE and type: "PIP_USER=no pip freeze".

Sometimes, you may need to use some more specialized packages that aren't pre-loaded. These can usually be installed using "pip install <package-name>" in the terminal in the IDE.

If you would you like to set up a repository for others to use, and want to make sure they have the right packages installed, it's helpful to have a requirements file, usually named "requirements.txt". A requirements file lists out the packages and version numbers that you used to run your code, and can easily be created from your local environment by typing "pip freeze > requirements.txt".

When a repository has a requirements.txt file, you can open the Leap IDE and install all of the Python packages at once using the terminal and typing "pip install -r requirements.txt".

An alternative method that will start up any new workspaces from your repository with these requirements.txt packages pre-loaded is to use a yml file. Create a new file in your repository named ".gitpod.yml", and include only these two lines in that file:

- init: pip install -r requirements.txt

Now, when a new workspace is started up from this repository, it will automatically install your new additional packages from your requirements file. Note that when the IDE opens your new workspace, it may take a few extra seconds to finish installing the new packages. The green "run" button in the top right will be available when you open a python file and the packages are ready to be used.

To check that your additional packages have been installed in the Leap IDE (with either the pip install or .yml file method), type "pip freeze" on the terminal to see the additional packages with version numbers.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.