没有root访问权限升级pip

时间:2016-03-04 21:34:12

标签: python pip

我正在尝试在超级计算机中使用pip 8,我没有root权限。从以下网站下载pip后:

https://pip.pypa.io/en/stable/installing/

我做:

myname@edison04:~/software/pip> python get-pip.py --prefix=~/local_python_lib/
Collecting pip
  Using cached pip-8.0.3-py2.py3-none-any.whl
Collecting wheel
  Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, wheel
  Found existing installation: pip 1.5.4
    Uninstalling pip-1.5.4:
Exception:
Traceback (most recent call last):
  File "/tmp/tmplu5E1W/pip.zip/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/tmp/tmplu5E1W/pip.zip/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/tmp/tmplu5E1W/pip.zip/pip/req/req_set.py", line 725, in install
    requirement.uninstall(auto_confirm=True)
  File "/tmp/tmplu5E1W/pip.zip/pip/req/req_install.py", line 752, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/tmp/tmplu5E1W/pip.zip/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/tmp/tmplu5E1W/pip.zip/pip/utils/__init__.py", line 266, in renames
    shutil.move(old, new)
  File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 300, in move
    rmtree(src)
  File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
OSError: [Errno 13] Permission denied: '/global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/__init__.py'
You are using pip version 1.5.4, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

它试图删除我不想要的已经存在的点子(而且我没有权限)....我可以问我该怎么办?谢谢。

更多更新:添加--user无效:

myname@edison04:~/software/pip> python get-pip.py --prefix=~/local_python_lib/ --user
ERROR: Can not combine '--user' and '--prefix' as they imply different installation locations
You are using pip version 1.5.4, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

myname@edison04:~/software/pip> python get-pip.py  --user
Collecting pip
  Using cached pip-8.0.3-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-1.5.4
You are using pip version 1.5.4, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

这在某些位置安装了pip-1.5.4,但是我想使用pip 8.0.3代替...此外,当我找到已安装的pip,并尝试检查他们的版本...我认为它只是将我的本地bin连接到pip 1.5.4 global bin

key01027@edison04:~> find . -name "pip"
./software/pip
./local_python_lib/pip
./.local/bin/pip
./.local/edison/2.7.9/lib/python2.7/site-packages/pip
./.local/edison/2.7.9/bin/pip
./.cache/pip
key01027@edison04:~> cd .local/
key01027@edison04:~/.local> cd bin/
key01027@edison04:~/.local/bin> ls
pip  pip2  pip2.7
key01027@edison04:~/.local/bin> ./pip --version
pip 1.5.4 from /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
key01027@edison04:~/.local/bin> ./pip2 --version
pip 1.5.4 from /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
key01027@edison04:~/.local/bin> ./pip2.7 --version
pip 1.5.4 from /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)

我该怎么办?谢谢

此外,使用虚拟环境也无法解决此问题:

设置virtualenv后,它也无济于事......

(dev)key01027@edison08:~/software> which pip 
/global/homes/k/key01027/dev/bin/pip 
(dev)key01027@edison08:~/software> pip install --upgrade pip 
Cannot fetch index base URL https://pypi.python.org/simple/ 
Could not find any downloads that satisfy the requirement pip in /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg 
Downloading/unpacking pip 
Cleaning up... 
No distributions at all found for pip in /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg 
Storing debug log for failure in /global/homes/k/key01027/.pip/pip.log 

1 个答案:

答案 0 :(得分:1)

Python虚拟环境允许您在同一系统上分割项目的其他依赖项,从而解决了这个问题。

大多数锁定系统仍然提供virtualenv,如果没有 - 请联系您的系统管理员。

http://docs.python-guide.org/en/latest/dev/virtualenvs/

https://pypi.python.org/pypi/virtualenv