python - 使用 pip 和 requirements.txt 在弹性 beanstalk 上安装 scikit-learn 和 scipy

标签 python amazon-web-services pip

当部署到 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/

相关文章:

python - 操作方法 - 更新实时运行的 Python 应用程序

python - 长格式的 Pandas 数据框缺少月份

ubuntu - 无法通过 apt-get 在我的 Ubuntu 9.04 上安装 pip

ruby-on-rails-3 - 不是由 eb init 创建的 git aws.push 命令

python - 如何在 Windows 中使用 git bash 设置 python 路径?

python - 如何卸载通过 Pip 安装的 Python 包引入的依赖项?

python - 无法将列表对象传递到模板瓶中

python - PyQt 在(Qt?)更新后启动时崩溃

ios - 在 Swift 中集成 Amazon Simple Email Services API 时出现问题

amazon-web-services - AWS Lambda 上的 .NET Core Web Api 在第一次请求时速度很慢