我正在尝试使用 pip 在本地安装一个包~/.local
。问题是该软件包(在旧版本中)已经在系统上全局可用。即使全局 python 包目录不在my 中PYTHONPATH
,pip 仍然拒绝安装,认为包要求已满足。这类似于此处描述的问题,除了我没有使用sudo
因此解决方案不适用:pip - 要求已经满足?
如果我做:
pip install --user numpy
它说:
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/dist-packages/numpy-1.6.2-py2.7-linux-x86_64.egg
但是,/usr/local/lib/...
不在我的PYTHONPATH
. 里面唯一的东西PYTHONPATH
是~/.local
。
如果我尝试这样做:
pip install --user --upgrade numpy
它下载 numpy 并编译它,然后认为我正在进行全局安装,尽管有 --user标志,我得到:
Installing collected packages: numpy
Found existing installation: numpy 1.6.2
Uninstalling numpy:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 261, in run
requirement_set.install(install_options, global_options)
File "/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1162, in install
requirement.uninstall(auto_confirm=True)
File "/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 495, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1492, in remove
renames(path, new_path)
File "/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg/pip/util.py", line 273, in renames
shutil.move(old, new)
File "/usr/lib/python2.7/shutil.py", line 300, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/bin/f2py'
如何解决这个问题?我不确定为什么它在传递--user
标志时会尝试做任何需要全局权限的事情。
有没有办法告诉 pip 只使用~/.local
并忽略系统上的所有其他内容?(我不想用virtualenv!这里没必要,我不想要多个环境,只要一个。)