5.6. pip

Attention

Remember to check the correct Virtualenv is activated before using pip to install software.

5.6.1. Installing apps

There are various pip commands but the most useful is:

pip install APP_NAME

5.6.1.1. Existing project

If you have downloaded an existing project with a requirements file already, navigate to the folder containing the requirements file then:

pip install -r requirements.txt

5.6.2. Uninstalling apps

To uninstall an app:

pip uninstall APP_NAME

If you are developing a Django app and want to remove an app as well as tables it has created in the database:

python manage.py sqlclear APP_NAME
pip uninstall APP_NAME

Note

If that gives an error about migrations, delete the migrations folder then try again.

5.6.3. Updates

To update your requirements list with the latest packages:

pip freeze > requirements.txt

To update pip:

pip install --upgrade pip

To find packages that are out of date:

pip list --outdated --format=columns

To update a package:

pip install -U APP_NAME

5.6.3.1. Requirements consideration

Some people recommend using pip freeze however there is a downside to it. All dependencies are listed as well which can make upgrading more complicated. Another approach is to manually add each package you install, with the version number, to requirements.txt. When you update that package, any updated dependencies will also be installed. You can then manually edit the requirements.txt with the new version. This makes for a much cleaner list of requirements with upgrades simpler.