当部署到 elastic beanstalk 时,我不断收到错误:
Partial import of sklearn during the build process.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-Le610u/scikit-learn/setup.py", line 247, in <module>
setup_package()
File "/tmp/pip-build-Le610u/scikit-learn/setup.py", line 237, in setup_package
.format(scipy_req_str, instructions))
ImportError: Scientific Python (SciPy) is not installed.
scikit-learn requires SciPy >= 0.9.
Installation instructions are available on the scikit-learn website: http://scikit-learn.org/stable/install.html
我的 requirements.txt 里面有 scikit-learn 和 scipy。
为什么会这样?我不想手动安装软件包,印象中 pip 会为我整理安装顺序(它目前正在尝试在 scipy 之前安装 scikit-learn)。可能值得注意的是,相同的 requirements.txt 在我的本地计算机上运行得非常好。
我该怎么做才能解决这个问题?
编辑:如果我更改 requirements.txt 中条目的顺序,使 scipy 位于 scikit-learn 之上,它就可以正常工作。我仍然想知道为什么反过来会失败,因为 pip freeze > requirements.txt 将按字母顺序覆盖它。
最佳答案
Requirements files是包含要使用 pip
安装的项目列表的文件:
Logically, a Requirements file is just a list of pip install arguments placed in a file.
因此,您的 requirements.txt
中的条目将由 pip 按顺序处理。就像现在一样,pip doesn't have true dependency resolution scipy 在其 setup.py 中缺少适当的 install_requires
,你必须先告诉 pip install scipy 。 (感兴趣的可以看"setup.py vs requirements.txt" by Donald Stufft)
相同的 requirements.txt
在您的本地计算机上工作的原因可能是您在运行脚本之前安装了 scipy。您可以通过 virtualenv
创建一个干净的 python 环境来验证这一 pip 在您的计算机上并再次运行脚本。
关于python - 使用 pip 和 requirements.txt 在弹性 beanstalk 上安装 scikit-learn 和 scipy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33806443/