简体   繁体   中英

How to use upgraded pip from site-packages?

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM