在virtualenv中通过pip安装Matploblib以推送到Heroku [英] Install Matploblib via pip in a virtualenv to push to Heroku
问题描述
如何在Heroku上安装numpy,scipy,matplotlib?
How can I install numpy,scipy,matplotlib on Heroku?
所以首先在本地我要进行pip install matplotlib->我收到一条错误消息,说要安装numpy. 所以我做pip install numpy并得到一条错误消息
So first locally I'm doing pip install matplotlib -> i get an error saying install numpy.. so i do pip install numpy and get an error saying
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和更改的var,以便它们指向heroku软件包(http://stackoverflow.com/questions/9819968/running-scipy-on-heroku)?这仍然有必要吗?听起来有点痛苦> _<
...what do I do now? Typically I would just do apt-get install python-numpy ... but then I'm thinking pip won't pick it up and then Heroku will be unhappy when I push... also I see a previous post where they recompiled numpy,scipy, matplotlib and changed vars so that they pointed to heroku packages (http://stackoverflow.com/questions/9819968/running-scipy-on-heroku) ? Is this still necessary? Sounds somewhat painful >_<
推荐答案
Heroku如何安装依赖项
当您将代码推送到Heroku时,Heroku仅 查看您的requirements.txt
文件并安装其中列出的软件包.
How Heroku installs dependencies
When you push code to Heroku, Heroku will only look at your requirements.txt
file and install the packages that are listed in there.
Heroku不在乎您是如何(手动或使用pip freeze
)创建该文件的,因此没有什么可以阻止您将包添加到requirements.txt
文件中,只需在其中添加一行即可.需求的名称.
Heroku doesn't care about how you created that file (by hand, or using pip freeze
), so nothing prevents you from adding a package to the requirements.txt
file, you just have to add a line in there with the name of the requirement.
将matplotlib
行添加到requirements.txt
文件后,即可将代码推送到Heroku,它们将
Once you add the matplotlib
line to your requirements.txt
file, you can then push your code to Heroku, and they will figure out what to do with your matplotlib
requirement.
如果这行不通,您可以随时与Heroku联系,但是如果唯一的要求是python标头,那么Heroku上没有它,我会感到惊讶.
If that doesn't work, you can always contact Heroku, but if the only requirement is the python headers, I'd be surprised if it wasn't available on Heroku.
对于本地安装,Ben Mezger的回答是正确的,您只需要:
Regarding local installation, Ben Mezger's answer is right, you just have to:
-
apt-get install
python标头(这些不是 一个python包,因此请不要使用pip安装它们). Heroku可能已经提供了这些功能. - 使用pip安装软件包,然后它将正确编译.
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.
这篇关于在virtualenv中通过pip安装Matploblib以推送到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!