ImportError:没有名为applicationform.wsgi的模块

时间:2018-08-09 01:19:48

标签: python django python-2.7 amazon-web-services deployment

我正在AWS中部署应用程序,当我在虚拟环境中运行gunicorn以测试其是否正常运行时,我收到以下错误消息:

(venv) ubuntu@ip-172-31-14-232:~/applicationform/newProject$ gunicorn --bind 0.0.0.0:8000 applicationform.wsgi:application
[2018-08-09 00:52:20 +0000] [22973] [INFO] Starting gunicorn 19.9.0
[2018-08-09 00:52:20 +0000] [22973] [INFO] Listening at: http://0.0.0.0:8000 (22973)
[2018-08-09 00:52:20 +0000] [22973] [INFO] Using worker: sync
[2018-08-09 00:52:20 +0000] [22977] [INFO] Booting worker with pid: 22977
[2018-08-09 00:52:20 +0000] [22977] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/ubuntu/applicationform/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
ImportError: No module named applicationform.wsgi
[2018-08-09 00:52:20 +0000] [22977] [INFO] Worker exiting (pid: 22977)
[2018-08-09 00:52:20 +0000] [22973] [INFO] Shutting down: Master
[2018-08-09 00:52:20 +0000] [22973] [INFO] Reason: Worker failed to boot.

在AWS上测试应用程序,我还会收到内部服务器错误。

代码在Github https://github.com/sannicko/applicationform

1 个答案:

答案 0 :(得分:0)

您命令行中的applicationform.wsgi: application实际上告诉gunicorn在Python模块application()中运行名为applicationform/wsgi.py的函数。在您的情况下,工作目录下没有applicationform目录。{p>

您应该从~/applicationform/newProject目录运行它,然后应用程序名称应为~/applicationform,即:

newProject.wsgi