尽管满足全球要求,仍然使用pip在本地安装软件包

时间:2013-04-28 23:21:42

标签: python numpy pip setuptools pythonpath

我正在尝试使用pip在~/.local本地安装软件包。问题是程序包(旧版本)已在系统上全局可用。即使我的PYTHONPATH中的全局python包目录,pip仍然拒绝安装,认为满足了包的要求。这类似于此处描述的问题,但我没有使用sudo,因此解决方案不适用:pip - Requirement already satisfied?

如果我这样做:

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!这里没有必要,我不想要多个环境,只需要一个。)

1 个答案:

答案 0 :(得分:2)

Citing Marcus Smith(pip的维护者):

  

如果您认为全球网站已过期,并希望获得最新信息   用户站点,然后使用:
  pip install --upgrade --user SomePackage

因为(...)包(在旧版本中)已在全局系统上可用,您必须使用--upgrade选项,如上面Marcus所述。 卸载system numpy包可能是你使用的pip版本中的一个错误(1.2.1)。尝试使用当前版本,因为版本1.3和1.4

中修复了与--user选项相关的许多问题

修改

马库斯·史密斯points在后来的评论中提到了具体问题:

  

pip 1.3有#705,这对于使用--user和--upgrade至关重要   在一起。

相关问题