Training Missions

Missions: Using pip and virtualenv

Quick Reference

Installation instructions

Installing pip and virtualenv along with all of what they depend on can be hard at times, so we recommend that you follow the installation instructions given here.

pip commands

To install a package, type pip install foo where foo is the name of the package you want to install.

To uninstall a package, type pip uninstall foo where foo is the name of the package you want to uninstall.

To get a list of all of the Python packages currently installed in your environment, use the pip freeze or pip list commands.

You can also search the PyPI for packages. For instance, to search for all packages that contain the string "http" in their name(or description), type: pip search http

If you find yourself installing the same packages frequently in virtualenvs and don't want to wait for pip to download the package again for each separate install, type pip wheel foo before pip install foo to get extra-fast installs.

virtualenv/virtualenvwrapper commands

You can use the mkvirtualenv command to create a virtualenv, like so:

mkvirtualenv FooEnv

where FooEnv is the name of the virtualenv(which can be anything you like).

To get out of a virtualenv, simply type deactivate at the terminal.

To activate a virtualenv that has already been created, type workon followed by the name of the virtualenv that you wish to activate, like so:

mkvirtualenv TestEnv

You can delete a virtualenv by typing rmvirtualenv FooEnv at the terminal, where FooEnv is the name of the virtualenv that you wish to delete.

To list all of the virtualenvs that you have created so far, simply type lsvirtualenv at the terminal.

Other resources

If you wish to learn more about the tools covered in this mission, we recommend that you take a look at the following additional resources: