简体   繁体   中英

how to correct the path of pip (python2.7)

My system is ubuntu16.04 I have python2.7 and python3.5

after I use alias python=python3 && unalias python

python2.7 and python3.5 mixup

Then I find that I have two path of pip2.7

$ which -a pip
/usr/local/bin/pip
/home/user/.local/bin/

Then I remove python-pip $ sudo apt-get autoremove python-pip

and reinstall pip python get-pip.py --prefix=/usr/local/

$ which -a pip
/usr/local/bin/pip

when I try to install package the result is

$ sudo pip install numpy
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: numpy in /home/user/.local/lib/python2.7/site-packages (1.15.2)

How can I solve it? Any idea? Thanks a lot

  1. /usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/ init .py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown. warnings.warn(warning, RequestsDependencyWarning)
  2. Requirement already satisfied: numpy in /home/user/.local/lib/python2.7/site-packages (1.15.2)

When you run sudo like that it's HOME is still your (non-root) home. So any directory it creates, like the cache directly, will be owned by root. You just have to:

sudo rm -rf /home/user/.cache/pip/http

To remove the cache directory. Run it again as non-root and you won't see the error.

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