zacmwa
zacmwa

Reputation: 578

Django ImportError: No module named wyat.settings

I am trying to run python manage.py makemigrations and I get this error:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/zacmwa/.virtualenvs/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/zacmwa/.virtualenvs/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 316, in execute
    settings.INSTALLED_APPS
  File "/home/zacmwa/.virtualenvs/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/home/zacmwa/.virtualenvs/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/zacmwa/.virtualenvs/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named wyat.settings

I have used the command before in this project and it was working but now I am getting this error. I have followed the debugging procedure here:https://help.pythonanywhere.com/pages/DebuggingImportError and I can't find any error.

"""
WSGI config for wyat project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""

import os
import sys

path = '/home/zacmwa/env/wyat/wyat'
if path not in sys.path:
   sys.path.append(path)

os.environ["DJANGO_SETTINGS_MODULE"] = "wyat.settings"
#
## then, for django >=1.5:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Changing the path name in the wsgi file does not change the error message it still says ImportError: No module named wyat.settings

Upvotes: 0

Views: 1012

Answers (1)

helioascorreia
helioascorreia

Reputation: 86

Hi you have to show your project structure so I can help you more.

When I had some error like that, it was that sometimes my pycharm create an init.py on the root and that gives me an error like that, if you had a file like that delete it.

Besides that show me your manage.py, because thats the file that calls the makemigration. For example if your project is config your manage.py has to be something like that.

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
    try:
        from django.core.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            )
        raise
    execute_from_command_line(sys.argv)

And your wsgi you don't need to change it.

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

application = get_wsgi_application()

Give me mor info like django version and python version

Upvotes: 1

Related Questions