Question

I'm trying to setup a local django installation, but am facing a lot of problems in configuring it properly.

Trying to start the server doesn't work:

admins-macbook:myproject Admin$ python manage.py runserver 8080

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 8, in <module>
    from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 26, in <module>
   from django.views import static
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/views/static.py", line 95, in <module>
    template_translatable = ugettext_noop(u"Index of %(directory)s")
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 75, in gettext_noop
    return _trans.gettext_noop(message)
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 48, in __getattr__
    if settings.USE_I18N:
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/Admin/myapp/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings '{{ project_name }}.settings' (Is it on sys.path?): No module named {{ project_name }}.settings

I have mainly been following the directions here.

I am completely lost about what I may be doing wrong. I googled and found some people saying that either this could be because of naming conflicts between the project name or trying to use two installations simultaneously. I changed the name of my project, and checked to see that I only have one django installation, but still am facing the same problem. Can anyone help? Thanks for any ideas!


EDIT: Checking the paths

admins-macbook:Downloads Admin$ echo $PATH
/Users/Admin/myapp/lib/python2.7/site-packages/django/conf/myproject:/Users/Admin/myapp/lib/python2.7/site-packages/django/conf:/Users/Admin/myapp/lib/python2.7/site-packages/django:/Users/Admin/myapp/lib/python2.7/site-packages:/Users/Admin/myapp/lib/python2.7:/Users/Admin/myapp/lib:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

EDIT: Adding the directory structure (did not change, straight from django 1.4.2):

-bin
-contrib
-core
-(etc.)
-django
--conf
---__init__
---app_template
---urls
---myproject
----myapp
-----settings.py
-----urls.py
-----(etc.)
----manage.py
Was it helpful?

Solution

When manage.py is first created it includes a code that adds the path to the project's settings.py to the python path whenever a command (such as run server) is run. Since you changed the names of the folders, manage.py can't find the settings anymore.

Open up manage.py and change the old project name there to the new one. There are other places where this problem might show up so keep an eye for references to your old project's name that would cause trouble

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top