Jeff
Jeff

Reputation: 23

Install packages using pip for updated versions of python

I recently updated from Python 3.5 to Python 3.6 and am trying to use packages that I had previously downloaded, but they are not working for the updated version of Python. When I try to use pip, I use the command "pip install selenium" and get the message "Requirement already satisfied: selenium in /Users/Jeff/anaconda/lib/python3.5/site-packages" How do I add packages to the new version of Python?

Upvotes: 0

Views: 119

Answers (1)

nerdenator
nerdenator

Reputation: 1307

First, make sure that your packages do have compatibility with the version of Python you're looking to use.

Next, run pip freeze > requirements.txt in the base directory of your Python project. This puts everything in a readable file to re-install from. If you know of any packages that require a certain version that you'll want to re-install, put package==x.x.x (where package is the package name and x.x.x is the version number) in the list of packages to make sure it downloads the correct version.

Run pip uninstall -r requirements.txt -y to uninstall all packages. Afterwards, run pip install -r requirements.txt.

This allows you to keep packages at the correct version for the ones you assign a version number in requirements.txt, while upgrading all others.

Upvotes: 1

Related Questions