J Wang
J Wang

Reputation: 2115

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

Upvotes: 4

Views: 1556

Answers (1)

Christian Will
Christian Will

Reputation: 1695

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 .

Upvotes: 5

Related Questions