没有root访问权限的升级pip [英] upgrade pip without root access
问题描述
我试图在没有超级用户访问权限的超级计算机中使用pip 8.从以下位置下载点子后:
I am trying to use pip 8 in a super computer where I don't have root access. After downloading pip from:
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.
它试图删除我不想(并且我没有权限)的已经存在的点....我可以问我该怎么办?谢谢.
It tries to remove the already existing pip which I don't want to (and I don't have permissions to).... May I ask what can i do? Thank you.
更多更新:添加--user无效:
A few more updates: adding --user does not help:
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并尝试检查其版本时...我认为这只是将我的本地垃圾箱链接到pip 1.5.4全局垃圾箱
This installs pip-1.5.4 on some location, however I want to use pip 8.0.3 instead... Further more, when i locate the installed pip, and try to check their version... I think it just links my local bin to the 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)
我该怎么办?谢谢
进一步,使用虚拟环境也不能解决此问题:
further, using virtual env also does not solve this problem:
设置virtualenv后,它也无济于事...
After set up the virtualenv, it also does not help...
(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
推荐答案
Python虚拟环境通过允许您将项目的依赖项与同一系统中的其他项分开来解决此问题.
Python Virtual Environments solve this problem by allowing you to segment off your project's dependencies from others on the same system.
大多数锁定的系统仍会提供virtualenv,否则请与系统管理员联系.
Most locked down systems still provide virtualenv, if not - contact your system administrator.
http://docs.python-guide.org/en/latest /dev/virtualenvs/
https://pypi.python.org/pypi/virtualenv
这篇关于没有root访问权限的升级pip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!