简体   繁体   中英

App Engine + Django: ImportError: No module named django.core.wsgi

I'm deploying a simple Django app to Google App Engine. How can I fix the following?

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 96, in LoadObject
    __import__(cumulative_path)
  File "/base/data/home/apps/.../20171104t152156.405293023907909181/mysite/wsgi.py", line 12, in <module>
    from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi

You're getting the ImportError because Django is not in your sys.path .

If you want to use one of the built-in Django versions from the App Engine SDK, simply add this to your app.yaml (it's not necessary to install the Django library separately):

libraries:
- name: django
  version: "1.4"

Update:

If you want to include your own Django version with your app (eg. to use a recent version > 1.5), don't add the above line and instead install the library directly into your project's root directory:

$ cd myapp/
$ pip install django -t .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM