0

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?

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
Goku95
  • 71
  • 12

2 Answers2

4

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.)

chepner
  • 497,756
  • 71
  • 530
  • 681
  • still having the same issue, `which pip` returns `myenv/bin/pip` but `pip --version` still points to `/usr/local/apps/python-3.8.3/lib/python3.8/site-packages/pip` – Goku95 Jan 07 '22 at 15:14
1

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.

pedro_bb7
  • 1,601
  • 3
  • 12
  • 28
  • won't this specify where the libraries are being installed by pip. I want to change the version of `pip` itself which is used. Specifically, the pip version installed in `.local/lib/python3.8/site-packages` – Goku95 Jan 07 '22 at 15:20