冻结 OS X 上的 pip 要求、NumPy 和 SciPy
我有一个 pip 需求文件,我将其与 virtualenv 一起使用来自动获取应用程序的依赖项。
该应用程序依赖于 NumPy 和 SciPy,因此我的 pip 要求文件包括:
numpy==1.5.0
scipy==0.8.0
但是,在新的 virtualenv 中运行此 pip 时,安装失败并出现以下错误:
File "/Users/x/virtualenv/deploy/src/scipy/setup.py", line 58, in svn_version
from numpy.compat import asstr
ImportError: No module named numpy.compat
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
发生这种情况是因为 SciPy 需要在构建之前安装 NumPy。因此,如果我删除 SciPy,然后手动添加 SciPy(pip install scipy),它就可以工作。
鉴于 pip 不按任何特定顺序安装,我该如何解决此问题?
I've got a pip requirements file that I'm using with virtualenv to automatically grab dependencies for my application.
The application depends on both NumPy and SciPy and as such my pip requirements file includes:
numpy==1.5.0
scipy==0.8.0
However, when running this pip in a new virtualenv, the installation fails with the following error:
File "/Users/x/virtualenv/deploy/src/scipy/setup.py", line 58, in svn_version
from numpy.compat import asstr
ImportError: No module named numpy.compat
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
This happens because SciPy requires NumPy to be installed before it will build. Therefore, if I remove SciPy and then manually add SciPy afterwards (pip install scipy), it works.
How can I resolve this problem given that pip does not install in any particular order?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你不能。 Pip 和 setuptools 不是标准工具 - 我们试图善意地支持它们,但它很脆弱。特别是,因为 scipy setup.py 需要 numpy 才能运行,所以它无法使用 install_requires 参数运行。
I don't think you can. Pip and setuptools are not standard tools - we try to support them on a good-will basis, but it is brittle. In particular, because scipy setup.py needs numpy to run, it cannot work using the install_requires argument.
我刚刚遇到了完全相同的问题!幸运的是,pip 的最新开发版本按照需求文件中列出的顺序安装软件包。
我使用此命令进行了更新(它需要 Mercurial 因为 pip 托管在 Bitbucket):
I just ran into the exact same problem! Luckily the latest development version of pip installs packages in the same order they are listed in the requirements file.
I updated with this command (it needs Mercurial since pip is hosted on Bitbucket):