【问题标题】:how to correct the path of pip (python2.7)如何更正pip的路径(python2.7)
【发布时间】:2019-03-08 05:51:16
【问题描述】:

我的系统是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(warning, RequestsDependencyWarning)
  2. 已满足要求:/home/user/.local/lib/python2.7/site-packages (1.15.2) 中的 numpy

【问题讨论】:

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


    【解决方案1】:

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

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

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

    【讨论】:

    • 我删除了缓存目录,我需要重新安装python包,然后它才能工作。感谢您的回复
    猜你喜欢
    • 2017-05-29
    • 2019-07-17
    • 2014-12-03
    • 2021-09-14
    • 1970-01-01
    • 2018-07-20
    • 2019-06-07
    • 2021-03-17
    • 2018-06-30
    相关资源
    最近更新 更多