2

如何在 Heroku 上安装 numpy、scipy、matplotlib?

所以首先我在本地做 pip install matplotlib -> 我得到一个错误说 install numpy.. 所以我做 pip install numpy 并得到一个错误说

  File "/home/sghose/myapp/helloflask/build/numpy/numpy/distutils/command/build_src.py", line 385, in generate_sources

    source = func(extension, build_dir)

  File "numpy/core/setup.py", line 410, in generate_config_h

    moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)

  File "numpy/core/setup.py", line 41, in check_types

    out = check_types(*a, **kw)

  File "numpy/core/setup.py", line 271, in check_types

    "Cannot compile 'Python.h'. Perhaps you need to "\

SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/sghose/myapp/helloflask/build/numpy

...现在我该怎么做?通常我只会做 apt-get install python-numpy ...但后来我想 pip 不会拿起它,然后当我推动 Heroku 时会不高兴...我还看到他们重新编译 numpy 的以前的帖子,scipy,matplotlib 并更改了变量,以便它们指向 heroku 包(http://stackoverflow.com/questions/9819968/running-scipy-on-heroku)?这还有必要吗?感觉有点痛>_<

4

2 回答 2

3

Heroku 如何安装依赖项

当您将代码推送到 Heroku 时,Heroku只会查看您的requirements.txt文件并安装其中列出的包。

如何列出这些依赖项

Heroku 不关心您是如何创建该文件的(手动或使用pip freeze),因此没有什么能阻止您将包添加到requirements.txt文件中,您只需在其中添加一行带有需求名称的行。

这如何解决您的问题

matplotlib行添加到requirements.txt文件后,您可以将代码推送到 Heroku,他们会弄清楚如何处理您的matplotlib要求。

如果这不起作用,您可以随时联系 Heroku,但如果唯一的要求是 python 标头,那么如果 Heroku 上没有它,我会感到惊讶。


Regarding local installation, Ben Mezger's answer is right, you just have to:

  • apt-get install the python headers (these are not a python package, so you don't install them with pip). Heroku likely has those available already.
  • Install the package using pip, it will then compile properly.
于 2012-10-30T00:47:34.290 回答
0

你需要安装 python-dev

apt-get install python-dev

或者

apt-get install python-devel
于 2012-10-30T00:17:02.520 回答