Home > Software design >  How to use upgraded pip from site-packages?
How to use upgraded pip from site-packages?

Time:01-08

When I run pip --version it returns the default path /usr/local/apps/python-3.8.3/lib/python3.8/site-packages/pip. However, when I run pip install --upgrade pip it installs the new pip to /home/username/.local/lib/python3.8/site-packages, but the pip command still uses the old path ie: system default. I am on a university computing cluster and I don't have root access. Which settings should I modify to ensure that the pip command uses the upgraded pip from the local folder?

CodePudding user response:

You should probably be using a virtual environment to avoid any locally installed pip.

python3 -mvenv myvenv

will install pip to myvenv/bin/. You can then run myvenv/venv/pip install --upgrade pip, and it will perform the upgrade in your virtual environment. (You can also activate the virtual environment with . ./myvenv/bin/activate, after which ./myvenv/bin will be at the front of your search path for the rest of the shell session, allowing you to just run pip as before.)

CodePudding user response:

According to How to change default install location for pip

You can set the following environment variable:

PIP_TARGET=/path/to/pip/dir

Answer provided by @chepner is better as you can isolate your virtual environments. One installation won't overwrite another one when you upgrade and can set to specific versions.

  •  Tags:  
  • Related