Django 1.5b1: running django-admin.py causes the error "No module named settings"

I recently installed Django-1.5b1. My system configuration:

  • OSX 10.8
  • Python 2.7.1
  • Virtualenv 1.7.2

When I call the django-admin.py command, I get the following error

(devel)ninja Django-1.5b1: django-admin.py Usage: django-admin.py subcommand [options] [args] Options: -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output --settings=SETTINGS The Python path to a settings module, eg "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used. --pythonpath=PYTHONPATH A directory to add to the Python path, eg "/home/djangoprojects/myproject". --traceback Print traceback on exception --version show program version number and exit -h, --help show this help message and exit Traceback (most recent call last): File "/Users/sultan/.virtualenvs/devel/bin/django-admin.py", line 5, in <module> management.execute_from_command_line() File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 452, in execute_from_command_line utility.execute() File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 375, in execute sys.stdout.write(self.main_help_text() + '\n') File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 241, in main_help_text for name, app in six.iteritems(get_commands()): File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py", line 108, in get_commands apps = settings.INSTALLED_APPS File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py", line 52, in __getattr__ self._setup(name) File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup self._wrapped = Settings(settings_module) File "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__ raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings 

Did anyone have the same mistakes? Can anyone advise or help with it?

Thank,

The sultan

+7
python django macos
Dec 08 '12 at 8:22
source share
6 answers

I had the same problem when starting a new project. I solved the problem by specifying this command on the command line:

 export DJANGO_SETTINGS_MODULE= 

this way I turned off the variable pointing to the " settings " file (discovered by env | grep DJANGO_SETTINGS_MODULE ) that I set before using virtualenv

after resetting the variable, django-admin.py script worked like a charm!

+23
Jun 20 '13 at 14:02
source share

I had the same problem as you did, and I did not come up with a good solution other than adding my project folder to PYTHONPATH as follows:

 export PYTHONPATH="/absolute/path/to/django/project/folder:$PYTHONPATH" 

where my <project> is in /absolute/path/to/django/project/folder/<project> . I add the export command to the end of my env/bin/activate script, so this happens every time virtualenv is initialized.

The only difference between our two situations is that I use several settings files instead of one settings.py module.

You can also call django-admin.py from the folder containing your Django project, as follows:

 python ~/.virtualenvs/devel/bin/django-admin.py <command> 

so that it recognizes your current working directory as part of the path.

Hope this makes sense. This is awkward to explain, making it difficult to find an answer.

+5
Feb 21 '13 at 6:03
source share

Perhaps your problem is related to this: Invalid python path in script header

If you want to do anything other than create a new django project inside your venv, you should call python manage.py (of course whereis python should return your venv executable)

0
Dec 09
source share

Do not run the script from a direct path to the django library; run it from any other way. It seems you cd to the directory where django is installed (or where you downloaded and expanded it), and then ran the command from there.

So try the following:

 (devel)ninja Django-1.5b1: cd (devel)ninja: django-admin.py startproject foo 
0
Dec 09
source share

Are you sure you are running django-admin from a virtual django installation? Possibly the path / to / virtualenv / bin / django-admin.py

-one
Dec 08
source share

for a simple solution you can try

python. \ Scripts \ django-admin.py startproject projectname

after that run

-one
Oct 31 '17 at 6:04 on
source share



All Articles