Forums

Django "Could not import settings"

Hi,

I'm trying to deploy my first Django app and I really don't know what I'm doing. I developed it on my computer and cloned the git repo to PythonAnywhere. I followed the instructions here but I'm running into problems. My settings file is at '/home/jfhc/GitHub/AG/ASCGur/ASCGur/settings.py'. My wsgi file looks like this:

# +++++++++++ DJANGO +++++++++++
import os
import sys

## assuming your Django settings file is at '/home/my_username/projects/my_project/settings.py'
path = '/home/jfhc/GitHub/AG/ASCGur'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'ASCGur.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

However, when I try to access the site, I get this error:

ImportError: Could not import settings 'ASCGur.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'ASCGur'

I've been banging my head against this for a couple of hours and I'm not getting anywhere. Any ideas?

That sounds odd. Would you mind if I took a look at your files? That would probably make it easier to debug.

Sure, thanks! How can I give you access to them?

Thanks. You don't need to do anything -- we just always ask before looking at people's stuff (unless they're doing something that's causing systemwide problems, which almost never happens, or they're doing something naughty like using us to hack other sites and we have to stop them).

I'll have a look now and post back here.

OK, I don't see a directory /home/jfhc/GitHub/AG/ASCGur. Did you mean /home/jfhc/GitHub/AsciiImgur/ASCgur?

Sorry yep, that's the one. I've been renaming things too much!

No problem! Let me know if that doesn't fix it.

Thanks for the help, it seems like things are named consistently but the same problem is arising

Looks like a casing problem -- your WSGI file has ASCGur where it should be ASCgur.

Well. I feel stupid! :P thanks so much for the help!

Hey, we all miss stuff like that :-) Glad to help.

Hi, I'm having the same issue. But I can't find any typo :-)

I'm working with a virtualenv to have python 2.7 and django1.6

Here is my wsgi.py

activate_this = '/home/putyourlitterhere/.virtualenvs/django16/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this)

import os
import sys

project_home = '/home/putyourlitterhere/cms'
if project_home not in sys.path:
    sys.path.append(project_home)

# set environment variable to tell django where your settings.py is
os.environ['DJANGO_SETTINGS_MODULE'] = 'cms.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

my project folder is: /home/putyourlitterhere/cms my settings.py file is in: /home/putyourlitterhere/cms/cms/settings.py

I also checked the permissions of settings.py but I cant find anything. How could I check if it is really loading my virtualenv?

If there are tracebacks in your error log, and they include the path to your virtualenv (inside .virtualenvs), then it's definitely being activated correctly.

things to check:

  • are there any errors in the settings file? can you run it from the command-line?
  • is there a __init__.py in the cms/cms folder?
  • have you double- and triple- checked for typos?

Thank you for your help!

  • I can run the settings.py from a bash with python and it does not give any error. I set up the web app by manual configuration and from my understanding the wsgi.py looks like the predefined one. The settings.py was created by django 1.6 on my local machine
  • there is an init.py but it is empty
  • I have checked the wsgi.py and the settings.py for typos but I can't find any. is there another place to look for?

Strange.... can you run the wsgi file from the command-line?

yes, I can. My CPU allowance is off currently. I will check again tomorrow... maybe it's working now? Eventhough I didn't change anything by mean.

Hello again,

it still doesn't work. Same error:

2014-06-10 12:08:42,698 :ImportError: Could not import settings 'cms.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named settings

In my .../cms/cms/ folder there is also an wsgi.py. Is this ok?

Further, the settings.py in .../cms/cms also contains these lines:

ROOT_URLCONF = 'cms.urls'
WSGI_APPLICATION = 'cms.wsgi.application'

might this be causing the problem? I left the settings.py as it was created on my local machine.

The extra WSGI file should be fine, and I don't think the extra stuff in the settings file is an issue either.

What happens if you start a bash console, go to the directory that's specified as project_home in your WSGI file, and run

python settings.py

...?

If I run python settings.py from /home/putyourlitterhere/cms I get:

python: can't open file 'settings.py': [Errno 2] No such file or directory

because the file is in /home/putyourlitterhere/cms/cms. So if I run it from there I get nothing. No error no success. If I

echo $?

it returns 0

I realized that whatever path I set as project_home in my /var/www/putyourlitterhere/wsgi.py the error message stays the same. E.g. if I put

project_home = '/home/putyourlitterhere/cms/foobar_nonsense'

there the error stays the same: Could not import settings 'cms.settings'
Does this help anything? If you have access, you can also have a look at my files.

Aaaaaah OK. I think I've figured it out. The problem is that your app's name (cms) conflicts with the name of one of the system-installed packages:

python -c"import cms; print cms"

it's odd, I would have thought that activating the virtualenv would hide that system package, but maybe the execfile formulation doesn't do that... intriguing.

In the meantime, if you rename your project to something that doesnt clash (even just cms2), then things should work!

Aha: from the virtualenv docs on activate_this.py

global items will always be accessible (as if the --system-site-packages flag had been used in creating the environment, whether it was or not

YEAH! It works! Thank you very much. I would have never thought about that.

Excellent, thanks for confirming :-)

Hi, I have the same error - my settings.py cannot be found. This is my wsgi.py that I am making through the WSGI configuration file under the Web link. I am pulling my django app over from GitHub into my home directory the path to my files is: /home/lelap2/my_django_project/my_django_project/

Under the above path is my app-settings/ my_django_project/ manage.py . My settings.py is in app-settings/ as it always is.

I've gone through the process of creating an account and going through the steps a few times but can't figure this out. I have tried both path = '/home/lelap2' and path = '/home/lelap2/my_django_project' below

import os
import sys

## assuming your django settings file is at '/home/username/mysite/settings.py'
path = '/home/lelap2'
if path not in sys.path:
sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'my_django_project.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Have you done the other diagnostics that are listed above? To summarise:

  • Check that the settings.py that is referenced in the wsgi file exists and doesn't throw an error when you run it with python settings.py
  • Look for casing problems between what's on the disk and what's in the wsgi file

Thanks, I tried both of these. Running python settings.py does not return an error and my path names in the wsgi.py file are the same as those on the server.

I am running the "python settings.py" command in this directory: /home/lelap2/my_django_project/app-settings

I have not modified anything in the source code that I have pulled from GitHub. I am running this project successfully on Bluehost. Are there other places I should check to get this running on your servers?

Can I take a look at your code? We don't look at your private files without permission, but if you say it's OK then I can take a look and perhaps suggest something.

Yes that would be fine - please go ahead. Thanks very much!

OK, thanks. Checking now...

Right, I can see that you're using "anonymised" versions of directory names in your message above, so I'll try to use the same ones here... In your WSGI file you have this:

path = '/home/lelap2/my_django_project'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'my_django_project.settings'

That will mean that Python will look for the settings.py file in /home/lelap2/my_django_project/my_django_project/settings.py. But the file is in /home/lelap2/my_django_project/app-settings, so it won't find it.

It's a bit tricky to work out what you need to do here. Normally I'd suggest just changing the DJANGO_SETTINGS_MODULE value so that it has the correct package name in it. But app-settings.settings is not a valid package name in Python (because of the dash).

Two options that come to mind:

  • Add /home/lelap2/my_django_project/app-settings to sys.path as well as /home/lelap2/my_django_project, and then just set DJANGO_SETTINGS_MODULE to settings.
  • Rename the app-settings directory to app_settings, and then set DJANGO_SETTINGS_MODULE to app_settings.settings

Thank you very much - this is very helpful. I'll make this change.

Thank you very much - this is very helpful. I'll make this change.

Great! Just let us know if you have any further problems.

Incidentally (for anyone else that comes across this thread and is struggling with getting their django settings to import, or similar issues in other frameworks, we have a wiki page about wsgi / webapp import + sys.path issues

ImportError: Could not import settings

my settings.py is inside that folder /home/stevandoh/ananse/ananse/conf and this is my wsgi file

import os
import sys

## assuming your Django settings file is at '/home/my_username/projects/my_project/settings.py'
path = '/home/ananse/ananse/conf/'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'ananse.settings'
activate_this = '/home/stevandoh/ananse/ananse/ananse/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

# sys.path.append(' /home/ananse/ananse/conf')
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings")
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

can someone tell me what I'm doing wrong

Have you tried the debugging steps outlined in similar issues in other frameworks, we have a https://www.pythonanywhere.com/wiki/DebuggingImportError? Did they reveal anything?

i have a similar problem

never mind. just some missing slashes and underscores...

OK, thanks for the update.

I am having similar issues. I have gone through the posted link, but can't seem to find anything wrong. I might just be overlooking something. Could a staff member take a look at my code? Thanks

My settings file is located at /home/brobin/albatross/albatross/settings.py

wsgi.py

project_home = u'/home/brobin/albatross'
os.environ['DJANGO_SETTINGS_MODULE'] = 'albatross.settings'

My error log shows this:

ImportError: Could not import settings 'albatross.settings'

It turns out it was another issue entirely. I had to change my last tow lines of the wsgi.py file to this for it to work:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Thanks for posting that! That's a Django version thing -- the code above was for Django 1.3, and I think it will work with all versions up to 1.6, but won't work in 1.7. (That's one of the "weird and unhelpful errors" mentioned on this page.)

Hi ive tried all stuff as mentioned above but im still getting this error

importError: Could not import settings 'djangoproject.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named djangoproject.settings

My project is working normally on my ubuntu, i dont now whats the pb please help :)

my code in the wsgy file is

activate_this = '/home/mqamar1994/.virtualenvs/django17/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))


import os
import sys

path = '/home/mqamar1994/djangoproject/'
if path not in sys.path:
    sys.path.append('/home/username/djangoproject')

os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

i have created a virtualenv and im using python python 2.7, django 1.7

[edit by admin: formatting]

enter code hereactivate_this = '/home/mqamar1994/.virtualenvs/django17/bin/activate_this.py' execfile(activate_this, dict(file=activate_this))

import os import sys

path = '/home/mqamar1994/djangoproject/' if path not in sys.path: sys.path.append('/home/username/djangoproject')

os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoproject.settings'

import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

ive removed that error but i got this one now :(

django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

and morever in the tutuorial it says

from myapp import app as application # use this to import wsgi file of our project im unable to understand what exactly is app here

Can I take a look at your files? It might make it easier to work out what's going on. I can see them from our side, but we always ask permission first.

Yesss why not pleasee

OK, the problem right now (I can see that you've been making changes as you tried to fix the error) is that you're defining your path like this in the WSGI file:

path = '/home/mqamar1994/djangoproject/'

...and you're specifying the settings module like this:

os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoproject.djangoproject.settings'

This means that it's looking for the Django settings in the file /home/mqamar1994/djangoproject/djangoproject/djangoproject/settings.py.

However, your settings are actually in /home/mqamar1994/djangoproject/djangoproject/settings.py

So, you need to either remove the djangoproject from the path, or remove one of the djangoprojects from the DJANGO_SETTINGS_MODULE environment variable.

ive changed that but im still getting an error here

:django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

ive tried all sorts of stuff :'( im unable to solve please help

phewwwwww i ve done it :) i didnt upload my files in the virtual env i had created and my path was pointing towards that :) Thanks

hang on, that doesn't sound right. you shouldn't be manually uploading any files into your virtualenv...

The basic setup for django should looks something like this:

  • django project, including apps, views, models etc, lives somewhere in your home, eg /home/myusername/my-django-project
  • virtualenv lives in, eg, /home/myusername/.virtualenvs/my-virtualenv-name
  • wsgi config file calls activate_this from virtualenv folder
  • wsgi config adds django project path to sys.path (not the virtualenv path)
  • wsgi config sets DJANGO_SETTINGS_MODULE to, eg, myproject.settings
  • wsgi config sets application = get_wsgi_application()

But all your django code, your views, models etc, should live inside your normal project folder in your home, not inside the virtualenv folder...

Basically it's all set out in the instructions here: https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango

And any problems with import errors, there are some debugging instructions here: https://www.pythonanywhere.com/wiki/DebuggingImportError

I hate to suggest messing with things once you have a setup that works, but I think you're storing up problems for yourself later on.

I would recommend hitting the 'delete' button on your web app and starting again from scratch -- don't worry, hitting the delete button doesn't delete any of your files, and it makes a backup copy of your wsgi file, so you'll be able to go back to what you have now if you need to.

But I would start again from scratch if I was you, following the instructions again, substituting in:

  • a new path for your django project, eg "myproject" instead of "mysite"
  • a new name for your virtualenv, eg "newdjango17" instead of "django17"

Hi, I'm having the error:

ImportError: No module named settings

too.

My project is a Mezzanine project cloned from bitbucket. I can run both python settings.py and python wsgi.py and I don't see any typo.

Can you please take a look? (The project directory is /home/jeudyx/tuanisapps/).

hmm. Maybe try to put print statements in your wsgi.py

print >> sys.stderr, "Debug message here"

and see when the error occurs/if it gets past get_wsgi_application() before error-ing.

and also put it into settings.py to see if settings.py is ever imported.

also try to print what the value for os.environ django settings module is, and what the sys path is etc.

another thing to look out for is maybe if somewhere in your code you import settings erroneously.

Hi conrad,

I added the print on both the settings.py and the wsgi files, but in the error log file I don't see the message at all:

https://www.pythonanywhere.com/user/jeudyx/files/var/log/www.tuanisapps.com.error.log

It keep just saying: "ImportError: No module named settings". Notice that it doesn't include the name of the project (it should be tuanisapps.settings).

This is my wsgi file:

import os
import sys

path = '/home/jeudyx/tuanisapps/'
if path not in sys.path:
    sys.path.append(path)

from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tuanisapps.settings")
os.environ['DJANGO_SETTINGS_MODULE'] = 'tuanisapps.settings'

application = get_wsgi_application()

print >> sys.stderr, "Finished loading settings %s - %s \n  %s" % (os.environ['DJANGO_SETTINGS_MODULE'], real_project_name("tuanisapps"), sys.path)

As I mentioned, this is my first attempt to use a Mezzanine project in PythonAnywhere. I started the project locally and then cloned the repo in the server and ran the createdb and collectstatic there (but I did not started the mezzanine project in PA). I wonder if that is related.

I think it may be related to this

The main project directory having a init.py file (this came from Mezzanine) so the server expects a settings.py file there, and will not find it. very weird.

I removed the init.py from the main project dir (.ie, '/home/jeudyx/tuanisapps/') but now getting a 400: Bad request (which may be from Mezzanine too).

Will keep looking.

Problem fixed. This post helped. The issue seems to be with Mezzanine having the main project folder as an app (with a init.py file) so it was expecting a settings.py there.

Removing "." and "" from the sys.path in the wsgi script solves it.

I installed Grappelli no problem, but when I try to run python2.7 manage.py collectstatic I get :

File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/mykl/.virtualenvs/django18/local/lib/python2.7/site-packages/django/core/management/init.py", line 338, in execute_from_comm and_line utility.execute() File "/home/mykl/.virtualenvs/django18/local/lib/python2.7/site-packages/django/core/management/init.py", line 303, in execute settings.INSTALLED_APPS File "/home/mykl/.virtualenvs/django18/local/lib/python2.7/site-packages/django/conf/init.py", line 48, in getattr self._setup(name) File "/home/mykl/.virtualenvs/django18/local/lib/python2.7/site-packages/django/conf/init.py", line 44, in _setup self._wrapped = Settings(settings_module) File "/home/mykl/.virtualenvs/django18/local/lib/python2.7/site-packages/django/conf/init.py", line 92, 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 settings

any idea why?

That is baffling, although a quick google search seems to reveal other people having import problems with grapelli.

Try some of the debug print statements conrad suggests in his post above, but try putting them into your wsgi file as well as your settings file. The debugging tips here may also help: https://www.pythonanywhere.com/wiki/DebuggingImportError

Hi, thanks that helped...I didn't have the css directory created in myapp/static/myapp/

I created the css directory and now it's working.

same problem...I have my django project in a directory /home/user_name/djcode and while editing wsgi, I have set the path to /home/use_name/djcode/egsite and os.environ['DJANGO_SETTINGS_MODULE'] = "egsite.settings", since my settings.py lies at /home/user_name/djcode/egsite/egsite/settings.py. Am i doing the thing right...???Please Help...!!!

EDIT : Solved...changed path to /home/gambulance/home/user_name/djcode/egsite and DJANGO_SETTINGS_MODULE to egsite.settings and it worked for me...!!!

Hey Guys!

I have the same problem... I read all posts, but cant figure out the issue...

My path looks fine... My "python settings.py" shows no error or success... Someone can tell me what i miss?

Ty very much

Well, one of them is wrong, otherwise it would be working. Work through the steps here: https://www.pythonanywhere.com/wiki/DebuggingImportError

Hi, I am trying to bring up my first project, and encountering some issues...

The following errors occur: 1. No module named 'admin' 2. home/myname/myproj/myproj# python ./wsgi.py
Traceback (most recent call last):
File "./wsgi.py", line 13, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named wsgi

Can someone assist?

Thx!

Re: the command-line problem -- it looks like your web app is set up on the "Web" tab to use Python 3.4, so you would need to use a different Python interpreter to run anything from the command line:

python3.4 ./wsgi.py

That said, I'm not sure why you're running that WSGI file from the command line...?

Re: the "no module named 'admin'" error you get when you go to your site -- which version of Django have you written your code for?

Hi giles

Thanks for the prompt reply!

Running python3.4 ./wsgi.py from CLI does seem to work properly. I didn't write any code yet. just following the tutorial (unsuccessfully...)

Can you please advise?

So the remaining problem is the "no module named 'admin'" one you get when you go to your site, right?

If so, which tutorial are you following?

https://help.pythonanywhere.com/pages/DjangoTutorial

I have just notice that this guide relates to Django 1.3, and I use 1.3.7 ...bummer...

I will look for a more suitable guide...

Thx!

I don't think that's the problem, 1.3 and 1.3.7 are compatible.

The problem is more likely to be the fact that you're using Python 3.4, which defaults to Django 1.6. If you delete the web app and try again with Python 2.7 (which uses 1.3) then you would be OK.

However 1.3.x is actually quite old. I recommend you follow this tutorial for Django 1.7 instead.

Hi giles

Thanks again for your quick response.

I started everything from scratch using virtualenv (python3.4 + Django1.9) and things are looking better now.

Thx again!

Great! Thanks for confirming, I'm glad it's all working now :-)

Hello I am having the same problem. I had a complex file structure so i imported from my git handle but it cant locate app.settings for me. I tried whatever is specified here and that does not work for me. Can you help?

Hi there, try some of the debugging tips outlined here and let us know what you discover?

Hello, I have the same problem. Can you please help me? Here is my wsgi.py file:

import os
import sys

# assuming your django settings file is at '/home/Gooman/mysite/mysite/settings.py'
# and your manage.py is is at '/home/Gooman/mysite/manage.py'
path = '/home/Gooman/myproject/myproject'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

# then, for django >=1.5:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# or, for older django <=1.4
# import django.core.handlers.wsgi
# application = django.core.handlers.wsgi.WSGIHandler()

I have solved the problem. I needed to use path = '/home/Gooman/myproject' instead of path = '/home/Gooman/myproject/myproject'

Hi @Gooman,

the fact that django gives you two folders with the same name does make things confusing (mysite/mysite, or myproject/myproject...). We try and make it as unambiguous as we can in those wsgi file comments, but, anyway, glad you figured it out!

Hi,

I have the exact same problem as many people have mentioned in this forum. I am getting an error stating that there is no module named trydjango18.settings.(FYI, there project has no errors while trying to execute in local machine).

I tried all the possibilities to make it work, but coudn't. Could you please help me out?

Here is my wsgi.py file:

# This file contains the WSGI configuration required to serve up your
# web application at http://Aravind.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Django project

import os
import sys

# add your project directory to the sys.path
project_home = u'/home/Aravind/trydjango18'
# sys.path.append('/home/Aravind/trydjango18/trydjango18')
if project_home not in sys.path:
    sys.path.append(project_home)


# set environment variable to tell django where your settings.py is
os.environ['DJANGO_SETTINGS_MODULE'] = 'trydjango18.settings'

# serve django via WSGI
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
## If you're modifying this file to use Django 1.7 or higher, use the following
## instead of the two lines above:
# from django.core.wsgi import get_wsgi_application
# application = get_wsgi_application()

Thank you!

Sincerely, Aravind Harikumar

Can you try some of the debugging tips outlined here and let us know what you discover?

You should probably also use the application = get_wsgi_application() formulation, as per the comments in that file....

Thanks a lot for your help! Yes, the issue was due to not using "application = get_wsgi_application()". It is working now.

Kind regards, Aravind Harikumar

I have the same problem and I tried the run settings.py file

  • python settings.py works without an exception
  • backend file contains init.py

here is my wsgi.py file. Could you please help me out?

    import os
    import sys
    #

    path = '/home/jinxed/Foursquare-API-with-Django/backend'
    if path not in sys.path:
        sys.path.append(path)
    #
    os.environ['DJANGO_SETTINGS_MODULE'] = 'backend.settings'
    #
    ## then, for django >=1.5:
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()

and the full error message is this:

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 342, in execute
    self.check()
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 374, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 361, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/dja
ngo/urls/resolvers.py", line 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/dja
ngo/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/dja
ngo/urls/resolvers.py", line 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/importlib/__init_
_.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/jinxed/Foursquare-API-with-Django/backend/urls.py", line 21, in <modu
le>
    import settings
ImportError: No module named 'settings'

Have you worked through the debugging process here?

yes I had, but then I find out that I had other settings.py that I dont use. So it solved and sorry. I feel embarrassed :') thank you for your interest :)

Hi. I am facing the same issue.

Have tried everything mentioned in this thread. Please help :(

You can look over my files if need be.

Thank you :)

# +++++++++++ DJANGO +++++++++++
# To use your own Django app use code like this:
import os
import sys

# assuming your Django settings file is at '/home/myusername/mysite/mysite/settings.py'
path = '/home/alfarhanzahedi/martian'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'martian.settings'

## Uncomment the lines below depending on your Django version
###### then, for Django >=1.5:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Your site looks like it's working. Did you work out what the problem was?

hi, Iam getting the same error :(

this is my wsgi.py file:

""" WSGI config for mylist 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/3.1/howto/deployment/wsgi/ """

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mylist.settings')

application = get_wsgi_application()

could anyone please help me. Iam a beginner

Looks like you are missing the code that adds your web app directory to sys.path. See examples above.

Is it required? Coz I tried to deploy with pa_autoconfig.

If you're using pa_autoconfigure then it should automatically generate a WSGI file for you -- though from your other forum post it sounds like that script is not running far enough to generate that file.

I have the same problem and I tried the run settings.py file

python settings.py works without an exception backend file contains init.py here is my wsgi.py file. Could you please help me out?

import os
import sys
#

path = '/home/jinxed/Foursquare-API-with-Django/backend'
if path not in sys.path:
    sys.path.append(path)
#
os.environ['DJANGO_SETTINGS_MODULE'] = 'backend.settings'
#
## then, for django >=1.5:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application() and the full error message is this:

Traceback (most recent call last): File "./manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/init.py", line 367, in execute_from_command_line utility.execute() File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/init.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(args, cmd_options) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 342, in execute self.check() File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks issues.extend(super(Command, self)._run_checks(kwargs)) [url=https://www.webnovedad.com/spyera-descarga-gratis-iphone-android/]spyera[/url], File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/management/base.py", line 361, in _run_checks return checks.run_checks(*kwargs) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/core/checks/urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/django/utils/functional.py", line 35, in get res = instance.dict[self.name] = self.func(instance) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/dja ngo/urls/resolvers.py", line 313, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/dja ngo/utils/functional.py", line 35, in get res = instance.dict[self.name] = self.func(instance) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/site-packages/dja ngo/urls/resolvers.py", line 306, in urlconf_module return import_module(self.urlconf_name) File "/home/jinxed/.virtualenvs/mysite-virtualenv/lib/python3.4/importlib/__init_ _.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec File "<frozen importlib._bootstrap>", line 1471, in exec_module File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed File "/home/jinxed/Foursquare-API-with-Django/backend/urls.py", line 21, in <modu le> import settings ImportError: No module named 'settings'

You must to use a debug, for to localizate bug.

Based on your WSGI file, you need to have a settings file at /home/jinxed/Foursquare-API-with-Django/backend/backend/settings.py. Do you?