权限错误,pip安装

Permission error, pip install

我刚开始使用新版本的 fedora,我正在尝试 pip install pew,以便我可以在一些虚拟 python 环境中工作。

pip 安装正确,至少我是这么认为的。

>>> pip -V
pip 7.1.0 from /usr/lib/python2.7/site-packages (python 2.7)

我知道版本有点过时,但我至少有pip。现在,当我尝试抓住长椅时,就会发生这种情况。

>>> pip install pew
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pew
  Using cached pew-0.1.19-py2.py3-none-any.whl
Collecting pythonz-bd>=1.10.2 (from pew)
  Using cached pythonz_bd-1.11.2-py2-none-any.whl
Collecting shutilwhich (from pew)
  Using cached shutilwhich-1.1.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): setuptools>=17.1 in /usr/lib/python2.7/site-packages (from pew)
Collecting backports.shutil-get-terminal-size (from pew)
  Using cached backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
Collecting virtualenv-clone>=0.2.5 (from pew)
  Using cached virtualenv-clone-0.2.6.tar.gz
Collecting pathlib (from pew)
  Using cached pathlib-1.0.1.tar.gz
Collecting virtualenv>=1.11 (from pew)
  Using cached virtualenv-15.0.2-py2.py3-none-any.whl
Installing collected packages: pythonz-bd, shutilwhich, backports.shutil-get-terminal-size, virtualenv-clone, pathlib, virtualenv, pew
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 308, in run
    strip_file_prefix=options.strip_file_prefix,
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 816, in install
    strip_file_prefix=strip_file_prefix
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 1013, in move_wheel_files
    strip_file_prefix=strip_file_prefix,
  File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 310, in clobber
    ensure_dir(destdir)
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 70, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/pythonz_bd-1.11.2.dist-info'

在我看来,仅基于 "Permission denied" 位,我应该做这样的事情。

sudo pip install pew

在询问我密码后,我一遍又一遍地收到此消息。

Collecting pew
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/pew/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/pew/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/pew/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/pew/

etc...

谁能帮我弄清楚如何在我的新 Fedora 版本上正确进行 pip 安装?

忘了我什至问过这个问题,但我需要 "sudo su" 因为我试图将 python 软件包安装到需要 root 的地方。

更永久的解决方法是使用 pew 来管理我的 python 环境。在 pew 环境中,我将 python 软件包安装到不需要 root 的地方,然后问题就消失了。