views:

125

answers:

3

Hi There,

I have a directory which hosts all my django app. *"C:\My_Projects".* I want to add this directory to my pythonpath so I can call the apps directly. I have *right clicked My Computer > Properties > Advanced System Settings > Environmental Variables. Then I added C:\My_Projects\; to my Path variable* but it still doesn't read the coltrane module. "Error: No module named coltrane"

A: 

You need to add to your PYTHONPATH variable instead of Windows PATH variable.

http://docs.python.org/using/windows.html

Tao
A: 

From Windows command line:

set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib

To set the PYTHONPATH permanently, add the line to your autoexec.bat. Alternatively, if you edit the system variable through the System Properties, it will also be changed permanently.

Yuval A
Your suggestion worked thanks. What do you mean add it to the autoexec.bat though?
mongoose_za
+1  A: 

These solutions work, but they work for your code ONLY on your machine. I would add a couple of lines to your code that look like this:

import sys
if "C:\\My_Python_Lib" not in sys.path:
    sys.path.append("C:\\My_Python_Lib")

That should take care of your problems

inspectorG4dget
Works for me. Win7, no problem.
dmitko
nice tip this one, Thanks
mongoose_za