2016-10-04 131 views
0

我想部署一個應用程序到heroku。 這是一個python/django應用程序,它在我的本地機器上運行良好。python/django:部署到heroku失敗

部署時,heroku會下載requirements.txt中定義的包,但會停止抱怨qpython無法建立,因爲它找不到numpy。但是從日誌輸出中可以看出numpy正在被下載,並且在qpython之前安裝。

我能想到的唯一的事情是日誌實際上是說 「收集」和「下載」,但不明確「安裝」...可能是因爲Heroku處理這種方式導致qpython之前建立numpy正在安裝?這是一個奇怪的假設,但我能想到的只有一個。無論如何,我不知道該怎麼做。

我將python定義爲runtime.txt中的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. 

回答

0

就像它說的那樣,你需要安裝numpy(它不會安裝在使用pip的heroku上)。

你必須使用一個buildpack在您的Heroku應用程式安裝numpy的:

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

+0

真棒哥們,我搜索了很多的文件,但找不到這個任何參考!非常感謝。 – faboolous