第一次在這裏使用Heroku。我想承載一個python Flask應用程序。開始瞭解事情的工作方式。 我想通過heroku local
命令在本地測試我的應用程序,但我得到這個錯誤:如何在本地測試Heroku python應用程序? ImportError:沒有名爲wsgi的模塊
ImportError: No module named wsgi
這裏是我的文件:
Procfile:
web: gunicorn choposcope.wsgi --log-file -
myapp.wsgi :
from choposcope import app as application
錯誤堆棧跟蹤:
[2016-12-01 18:36:21 +0100] [9916] [INFO] Starting gunicorn 19.6.0
6:36:21 PM web.1 | [2016-12-01 18:36:21 +0100] [9916] [INFO] Listening at: http://0.0.0.0:5000 (9916)
6:36:21 PM web.1 | [2016-12-01 18:36:21 +0100] [9916] [INFO] Using worker: sync
6:36:21 PM web.1 | [2016-12-01 18:36:21 +0100] [9919] [INFO] Booting worker with pid: 9919
6:36:34 PM web.1 | [2016-12-01 18:36:34 +0100] [9919] [ERROR] Exception in worker process
6:36:34 PM web.1 | Traceback (most recent call last):
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
6:36:34 PM web.1 | worker.init_process()
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
6:36:34 PM web.1 | self.load_wsgi()
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
6:36:34 PM web.1 | self.wsgi = self.app.wsgi()
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
6:36:34 PM web.1 | self.callable = self.load()
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
6:36:34 PM web.1 | return self.load_wsgiapp()
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
6:36:34 PM web.1 | return util.import_app(self.app_uri)
6:36:34 PM web.1 | File "/Users/Yann/Documents/dev/choposcope/env/lib/python2.7/site-packages/gunicorn/util.py", line 357, in import_app
6:36:34 PM web.1 | __import__(module)
6:36:34 PM web.1 | ImportError: No module named wsgi
6:36:34 PM web.1 | [2016-12-01 18:36:34 +0100] [9919] [INFO] Worker exiting (pid: 9919)
6:36:34 PM web.1 | [2016-12-01 18:36:34 +0100] [9916] [INFO] Shutting down: Master
6:36:34 PM web.1 | [2016-12-01 18:36:34 +0100] [9916] [INFO] Reason: Worker failed to boot.
[DONE] Killing all processes with signal null
6:36:34 PM web.1 Exited with exit code 3
另外,我不知道如果wsgi模塊應該默認安裝在燒瓶上。當我嘗試在我的虛擬環境中運行pip install mod_wsgi
,我得到這個錯誤:
pip install mod_wsgi
Collecting mod_wsgi
Using cached mod_wsgi-4.5.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/_1/bhy3l2kj5l36_859j956y87m0000gn/T/pip-build-h3zlPa/mod-wsgi/setup.py", line 284, in <module>
APR_INCLUDES = get_apr_includes().split()
File "/private/var/folders/_1/bhy3l2kj5l36_859j956y87m0000gn/T/pip-build-h3zlPa/mod-wsgi/setup.py", line 245, in get_apr_includes
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_1/bhy3l2kj5l36_859j956y87m0000gn/T/pip-build-h3zlPa/mod-wsgi/
你是怎麼安裝heroku的? – daphtdazz
不確定是什麼讓你覺得你需要Apache; Heroku完全不使用它,它在開發中肯定不是必需的。但是你們沒有給我們足夠的信息來回答這個問題。你的項目結構是什麼樣的?你在虛擬世界嗎?你安裝了哪些庫?你的proc文件是什麼?而且,最重要的是,* full *錯誤回溯是指什麼? –
我添加了您要求的詳細信息。一切都在同一個文件夾中。 – ypicard