python/django:部署到 heroku 失败

python/django: deployment to heroku fails

我正在尝试将应用程序部署到 heroku。 这是一个 python/django 应用程序,在我的本地机器上运行良好。

部署时,heroku 会下载 requirements.txt 中定义的包,但随后会停止抱怨 qpython 无法构建,因为找不到 numpy。但是从日志输出可以看出 numpy 正在下载,并在 qpython.

之前安装

我唯一能想到的是日志实际上说 "Collecting" 和 "Downloading",但未明确 "Installing"...难道是 heroku 处理此问题的方式导致 qpython 在安装 numpy 之前构建?这是一个奇怪的假设,但我能想到的唯一一个。无论如何,我不知道也不会知道该怎么做。

我在runtime.txt中定义python为python 2.7.12。

$ git push heroku-dev django6_12:master
Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 1.99 KiB | 0 bytes/s, done.
Total 21 (delta 16), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
/*...more output omitted for brevity */
remote: -----> Python app detected
remote: -----> Installing python-2.7.12
remote: -----> Noticed cffi. Bootstrapping libffi.
remote:      $ pip install -r requirements.txt
/*...more output omitted for brevity */
remote:        Collecting nodeenv==0.7.2 (from -r requirements.txt (line 36))
remote:          Downloading nodeenv-0.7.2.tar.gz
remote:        Collecting numpy==1.8.1 (from -r requirements.txt (line 37))
remote:          Downloading numpy-1.8.1-cp27-cp27m-manylinux1_x86_64.whl (14.6MB)
remote:        Collecting pandas==0.14.0 (from -r requirements.txt (line 38))
remote:          Downloading pandas-0.14.0.zip (7.3MB)
/*...more output omitted for brevity 
**Note how numpy is being installed** */
remote:        Collecting qpython==1.0.0 (from -r requirements.txt (line 112))
remote:          Downloading qPython-1.0.0.zip (75kB)
remote:            Complete output from command python setup.py egg_info:
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-build-NoEaTG/qpython/setup.py", line 19, in <module>
remote:                import numpy
remote:            ImportError: No module named numpy
remote:            
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-NoEaTG/qpython/
remote:  !     Push rejected, failed to compile Python app.



$ git push heroku-dev django6_12:master
Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (21/21), 1.99 KiB | 0 bytes/s, done.
Total 21 (delta 16), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
/*...more output omitted for brevity */
remote: -----> Python app detected
remote: -----> Installing python-2.7.12
remote: -----> Noticed cffi. Bootstrapping libffi.
remote:      $ pip install -r requirements.txt
/*...more output omitted for brevity */
remote:        Collecting nodeenv==0.7.2 (from -r requirements.txt (line 36))
remote:          Downloading nodeenv-0.7.2.tar.gz
remote:        Collecting numpy==1.8.1 (from -r requirements.txt (line 37))
remote:          Downloading numpy-1.8.1-cp27-cp27m-manylinux1_x86_64.whl (14.6MB)
remote:        Collecting pandas==0.14.0 (from -r requirements.txt (line 38))
remote:          Downloading pandas-0.14.0.zip (7.3MB)
/*...more output omitted for brevity 
**Note how numpy is being installed** */
remote:        Collecting qpython==1.0.0 (from -r requirements.txt (line 112))
remote:          Downloading qPython-1.0.0.zip (75kB)
remote:            Complete output from command python setup.py egg_info:
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-build-NoEaTG/qpython/setup.py", line 19, in <module>
remote:                import numpy
remote:            ImportError: No module named numpy
remote:            
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-NoEaTG/qpython/
remote:  !     Push rejected, failed to compile Python app.

正如它所说,您需要安装 numpy(它不会通过 pip 安装在 heroku 上)。

您必须使用构建包在您的 heroku 应用程序上安装 numpy:

https://github.com/thenovices/heroku-buildpack-scipy