在没有根失败的情况下安装pip

时间:2019-05-13 13:40:28

标签: python linux server pip

我正在尝试在非root用户的远程Linux服务器上安装pip3。当我键入以下内容时,我具有Python 2.7.15rc1和Python 3.6.7:

ls -la ~/.local/lib/python2.7/site-packages/

它按预期返回软件包,

drwx------ 2 user user   64 May 12 16:59 .
drwx------ 2 user user   64 May  7 15:58 ..
drwxrwxr-x 2 user user 4096 May 12 16:59 numpy
drwxrwxr-x 2 user user 4096 May 12 16:59 numpy-1.16.3.dist-info
drwxrwxr-x 2 user user   64 May 12 16:56 pip
drwxrwxr-x 2 user user 4096 May 12 16:56 pip-19.1.1.dist-info

ls -la〜/ .local / lib / python3.5 / site-packages /

I get:ls: cannot access '/home/.local/lib/python3.5/site-packages/': No such file or directory

我尝试重新安装pip3:

~$ wget https://bootstrap.pypa.io/get-pip.py
....(connecting to ..., saving to .... , saved)
~$ python3 get-pip.py --user
Collecting pip
...
Successfully installed pip-19.1.1
~$ echo "PATH=\$PATH:~/.local/bin" >> ~/.bashrc
~$ source ~/.bashrc
~$ pip3 install numpy --user
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

ps:..意味着一些额外的书面内容

该如何处理,我尝试安装一个虚拟环境,这就是我要得到的。

~$ pip install virtualenv --user
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name main

1 个答案:

答案 0 :(得分:2)

 for k, v in LANGS.iteritems():
    ll = pycountry.languages.get(alpha_2=v)
    if ll is not None:
        languages[k] = ll.name

rst_epilog = """.. |languages| replace:: {languages} """.format(languages=languages)

您希望bash使用echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc 中的点,而不是~/.local/bin中的点。因此,将/usr/local/bin放在路径中的所有其他条目之前。