environment variable DJANGO_SETTINGS_MODULE undefined
Next i tried to fix this by adding a Windows system variable:
variable: DJANGO_SETTINGS_MODULE
path: c:/temp/mysite (this is where my project lives)
Now after running the above command I get the following errors:
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 'c:\temp\mysite' (Is it on
sys.path? Does it have syntax errors?): No module named c:\temp\mysite
I tried adding the path to mysite to the sys.path of python.
>>>import sys
>>>sys.path.append('c:/temp/mysite')
This appends the directory to sys.path, but it does not save it I to
the path module I guess. The next time I imported sys, it was gone
again. How do I do this. Will it solve my problem?
Thx
On Sat, Dec 09, 2006 at 08:20:02AM -0800, Snirp wrote:
> environment variable DJANGO_SETTINGS_MODULE undefined
I assume mysite is the project you've created under c:\temp using
"django-admin.py startproject mysite". To use the shell, you need to
have the following environment variables set:
PYTHONPATH = c:/temp
DJANGO_SETTINGS_MODULE = mysite.settings
I haven't tested this, so you may have to play with the PYTHONPATH
format (slashes, etc.).
> >>>import sys
> >>>sys.path.append('c:/temp/mysite')
>
> This appends the directory to sys.path, but it does not save it I to
> the path module I guess.
sys.path.append affects only the process it is called in. Setting
PYTHONPATH should work for you.
With kind regards,
Baurzhan.
[C:\temp\mysite] has now been set in the following locations:
- As a value of the system variable "DJANGO_SETTINGS_MODULE"
- In sys.path
- As a PYTHONPATH windows registry value
None of this works.
Have you tried setting both variables in the system settings to the
values from my last e-mail and restarting the cmd shell you are starting
manage.py from? If you did and it didn't work for you, send the output
of the "set" command in cmd and the error message from manage.py.
With kind regards,
--
Baurzhan Ismagulov
http://www.kz-easy.com/
> [...]you need to have the following environment variables set:
>
> PYTHONPATH = c:/temp
> DJANGO_SETTINGS_MODULE = mysite.settings
I did just that and it works now, thx.
To recap and potentially make this post even more useful, what i
learned so far:
In: System properties -> Advanced -> Evironment variables
I have added the following system variables:
PYTHONPATH = c:\temp
DJANGO_SETTINGS_MODULE = mysite.settings
(solving my previously mentioned errors)
probably not solving my problems, but maybe useful
To add to the sys.path of Python:
Create a .PTH file within a directory on sys.path (pref.
.../python/lib/site-packages)
To add to PYTHONPATH
Edit the registry key:
HKEY-LOCAL/SOFTWARE/PYTHON/PYTHONCORE/2.5/PYTHONPATH/(default)