如何更正点子(python2.7)的路径

时间:2018-10-03 04:11:26

标签: python python-3.x python-2.7 pip ubuntu-16.04

我的系统是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)

我该如何解决?任何想法?非常感谢

  1. /usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/ init .py:83:RequestsDependencyWarning:加密的旧版本([1、2、3 ])可能会导致速度降低。   warnings.warn(警告,RequestsDependencyWarning)
  2. 已满足要求:/home/user/.local/lib/python2.7/site-packages(1.15.2)中的numpy

1 个答案:

答案 0 :(得分:1)

当您像这样运行sudo时,它的HOME仍然是您的(非根目录)家庭。因此,它创建的任何目录(如直接缓存)都将由root拥有。您只需要:

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

删除高速缓存目录。以非root用户身份再次运行它,您将看不到错误。