我的系统是ubuntu16.04 我有python2.7和python3.5
在我使用alias python=python3
和&unalias python
python2.7和python3.5混合
然后我发现我有两条pip2.7路径
$ which -a pip
/usr/local/bin/pip
/home/user/.local/bin/
然后我删除python-pip
$ sudo apt-get autoremove python-pip
并重新安装pip
python get-pip.py --prefix=/usr/local/
$ which -a pip
/usr/local/bin/pip
当我尝试安装软件包时,结果是
$ 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)
我该如何解决?任何想法?非常感谢
答案 0 :(得分:1)
当您像这样运行sudo
时,它的HOME仍然是您的(非根目录)家庭。因此,它创建的任何目录(如直接缓存)都将由root拥有。您只需要:
sudo rm -rf /home/user/.cache/pip/http
删除高速缓存目录。以非root用户身份再次运行它,您将看不到错误。