Discussion:
ImportError: No module named mysite.settings
Mark Phillips
2007-05-14 09:07:57 UTC
Permalink
Decided to try a clean slate. Set up Django on SME Server 7.1, which
is based on Centos 4.
Compiled and installed mod_python
Amended httpd.conf as follows:

LoadModule python_module modules/mod_python.so

and later on in the file...
<Location "/mysite/">
SetHandler python-program
PythonPath "['/usr/local/mysite'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonAutoReload On
</Location>

Downloaded Django into python2.3/site-packages with svn co http://
code.djangoproject.com/svn/django/trunk/django django

Restarted the server. Created a new project "mysite". Left the file
mysite.settings as created by "startproject". The manage.py validate
and runserver methods ran without errors.

Ran into trouble when attempting to browse to the site "www.myweb.com/
mysite". Here is the trace back from the browser:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

File "/usr/lib/python2.3/site-packages/django/core/handlers/
modpython.py", line 177, in handler
return ModPythonHandler()(req)

File "/usr/lib/python2.3/site-packages/django/core/handlers/
modpython.py", line 145, in __call__
self.load_middleware()

File "/usr/lib/python2.3/site-packages/django/core/handlers/
base.py", line 22, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:

File "/usr/lib/python2.3/site-packages/django/conf/__init__.py",
line 28, in __getattr__
self._import_settings()

File "/usr/lib/python2.3/site-packages/django/conf/__init__.py",
line 55, in _import_settings
self._target = Settings(settings_module)

File "/usr/lib/python2.3/site-packages/django/conf/__init__.py",
line 83, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it
on sys.path? Does it have syntax errors?): %s" %
(self.SETTINGS_MODULE, e)

EnvironmentError: Could not import settings 'mysite.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
mysite.settings

Where did I goof?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Steven Armstrong
2007-05-14 09:13:21 UTC
Permalink
Post by Mark Phillips
Decided to try a clean slate. Set up Django on SME Server 7.1, which
is based on Centos 4.
Compiled and installed mod_python
LoadModule python_module modules/mod_python.so
and later on in the file...
<Location "/mysite/">
SetHandler python-program
PythonPath "['/usr/local/mysite'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonAutoReload On
</Location>
Downloaded Django into python2.3/site-packages with svn co http://
code.djangoproject.com/svn/django/trunk/django django
Restarted the server. Created a new project "mysite". Left the file
mysite.settings as created by "startproject". The manage.py validate
and runserver methods ran without errors.
Ran into trouble when attempting to browse to the site "www.myweb.com/
Mod_python error: "PythonHandler django.core.handlers.modpython"
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)
File "/usr/lib/python2.3/site-packages/django/core/handlers/
modpython.py", line 177, in handler
return ModPythonHandler()(req)
File "/usr/lib/python2.3/site-packages/django/core/handlers/
modpython.py", line 145, in __call__
self.load_middleware()
File "/usr/lib/python2.3/site-packages/django/core/handlers/
base.py", line 22, in load_middleware
File "/usr/lib/python2.3/site-packages/django/conf/__init__.py",
line 28, in __getattr__
self._import_settings()
File "/usr/lib/python2.3/site-packages/django/conf/__init__.py",
line 55, in _import_settings
self._target = Settings(settings_module)
File "/usr/lib/python2.3/site-packages/django/conf/__init__.py",
line 83, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it
on sys.path? Does it have syntax errors?): %s" %
(self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'mysite.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
mysite.settings
Where did I goof?
<Location "/mysite/">
...
PythonPath "['/usr/local'] + sys.path"
...
</Location>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Mark Phillips
2007-05-14 14:14:16 UTC
Permalink
Post by Mark Phillips
<Location "/mysite/">
...
PythonPath "['/usr/local'] + sys.path"
...
</Location>
This worked.

I also tried using "/usr/local/mysite" which did eliminate the
problem finding mysite.settings but raised another one: no module
named mysite.urls.

Many thanks for the advice, Steven and Malcolm.

Happy days,

- Mark

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
ilDave
2007-05-14 14:41:15 UTC
Permalink
Check the permissions of the directory where your app lives, it has to
be readable by the webserver.
Post by Mark Phillips
Post by Mark Phillips
<Location "/mysite/">
...
PythonPath "['/usr/local'] + sys.path"
...
</Location>
This worked.
I also tried using "/usr/local/mysite" which did eliminate the
problem finding mysite.settings but raised another one: no module
named mysite.urls.
Many thanks for the advice, Steven and Malcolm.
Happy days,
- Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Mark Phillips
2007-05-15 15:18:31 UTC
Permalink
Post by ilDave
Check the permissions of the directory where your app lives, it has to
be readable by the webserver.
Good suggestion. I think it is root:wheel 755 but I will check.

- Mark

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Malcolm Tredinnick
2007-05-14 09:12:31 UTC
Permalink
Post by Mark Phillips
Decided to try a clean slate. Set up Django on SME Server 7.1, which
is based on Centos 4.
Compiled and installed mod_python
LoadModule python_module modules/mod_python.so
and later on in the file...
<Location "/mysite/">
SetHandler python-program
PythonPath "['/usr/local/mysite'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonAutoReload On
</Location>
Standard import path blunder: if you are going to import the thing as
mysite.settings, then the directory containing mysite/ had better be on
your python path (i.e. /usr/local/). With the way you've set your
PythonPath up, you probably want just "settings" as your
DJANGO_SETTINGS_MODULE.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Loading...