How to Update a Python Package Which Was Installed by Pip

According to The Ubuntu lifecycle and release cadence, Ubuntu 16.04 has full support until mid-2021.

Yet when I run:

pip install cryptography

it says:

Requirement already satisfied: cryptography in /usr/lib/python2.7/dist-packages (1.2.3)

cryptography 1.2.3 is from March, 2016.

The cryptography package fully supports Python 2.7, and there were dozens of new cryptography versions released since 2016, so why is it impossible to update it?

1 Answer

From results of man pip :

-U, --upgrade
         Upgrade all packages to the newest available version. 

The -U option of pip upgrades all package(s) that come after it in the same command to the newest available version. An exception is made where upgrading a package will conflict with a newer version of one of that package's installed dependencies, in which case the dependency package is kept at the newer version and an older version of the same dependency package is installed alongside it to allow both packages to be upgraded to the newest available version.

Open the terminal and type:

python -m pip install -U cryptography   

This command will upgrade the cryptography package from 1.2.3 to the latest version, 2.4.2.

Check the version of the upgraded cryptography Python module.

$ pip freeze | grep cryptography
cryptography==2.4.2
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest