pythondjangowagtail

Why am I receiveing 'no module named wagtail' error when I try to launch django app


I have an existing Django Project. I would like to use Wagtail with it. I have followed the instructions here: http://docs.wagtail.io/en/v1.9/getting_started/integrating_into_django.html

However when I try to launch my app, I receive the following error message from uWSGI:-

    *** Operational MODE: preforking ***
    Traceback (most recent call last):
      File "./core/wsgi.py", line 16, in <module>
        application = get_wsgi_application()
      File "/opt/django/env/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
        django.setup()
      File "/opt/django/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/opt/django/env/lib/python2.7/site-packages/django
/apps/registry.py", line 85, in populate
        app_config = AppConfig.create(entry)
      File "/opt/django/env/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
        mod = import_module(mod_path)
      File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
    ImportError: No module named wagtail
    unable to load app 0 (mountpoint='') (callable not found or import error)

ImportError: No module named wagtail

However I have installed wagtail.

I found this https://github.com/wagtail/wagtaildemo/issues/32

Which suggested

Please can you run pip freeze and paste the output here?

I have run pip freeze, and this was the result: -

Django==1.9.12
Pillow==3.0.0
Unidecode==0.4.20
Willow==0.4
argparse==1.2.1
assert-exists==0.0.0
backports.ssl-match-hostname==3.5.0.1
beautifulsoup4==4.5.3
caller-module==0.0.0
cp==0.0.0
distribute==0.7.3
django-appconf==1.0.1
django-autocomplete-light==3.2.1
django-compat==1.0.8
django-compressor==1.6
django-dual-authentication==1.0.0
django-hijack==2.0.1
django-htmlmin==0.8.0
django-ipware==1.1.2
django-mathfilters==0.3.0
django-modelcluster==3.0.1
django-taggit==0.22.0
django-treebeard==4.1.0
django-widget-tweaks==1.4.1
djangorestframework==3.6.2
evernote==1.25.1
html5lib==0.9999999
httplib2==0.9.2
not==1.7
oauth2==1.9.0.post1
olefile==0.44
pbr==1.8.1
public==0.0.0
publicsuffix==1.1.0
python-dateutil==2.2
pytz==2015.7
requests==2.13.0
setupfiles==0.0.0
simplejson==3.10.0
six==1.10.0
slackclient==1.0.5
stevedore==1.10.0
svn==0.3.36
uWSGI==2.0.11.2
url==0.1.5
virtualenv==13.1.2
virtualenv-clone==0.2.6
virtualenvwrapper==4.7.1
wagtail==1.9
webencodings==0.5
websocket-client==0.40.0
wheel==0.24.0
wsgiref==0.1.2

The next troubleshooting steps in link above, stated: -

What do you get if you enter the following lines at the python command line?

import wagtail; wagtail import wagtail.wagtailadmin; wagtail.wagtailadmin import wagtail.wagtailforms; wagtail.wagtailforms

Here is the result when I run those commands in python:

Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wagtail; wagtail
<module 'wagtail' from '/usr/local/lib/python2.7/dist-packages/wagtail/__init__.pyc'>
>>> import wagtail.wagtailadmin; wagtail.wagtailadmin
<module 'wagtail.wagtailadmin' from '/usr/local/lib/python2.7/dist-packages/wagtail/wagtailadmin/__init__.pyc'>
>>> import wagtail.wagtailforms; wagtail.wagtailforms
<module 'wagtail.wagtailforms' from '/usr/local/lib/python2.7/dist-packages/wagtail/wagtailforms/__init__.pyc'>
>>>

Why am I receiving the 'no module named wagtail' error?


Solution

  • It seems that you have two python 2.7 installed, perhaps a built in one, and a manually installed one. The one that shows the import error uses the python located at:

    /usr/lib/python2.7/
    

    While the one you had the module installed was located here:

    /usr/local/lib/python2.7/
    

    You will need to either install wagtail to the first python or change the Django Project to use the second python.