Soviet
Soviet

Reputation: 119

PATH/PYTHONPATH is not working

I've made a separate directory for my django modules. I've added this directory to my PATH variable. I've also created a new PYTHONPATH variable, since it wasn't there. I've added modules to settings.py. But when im trying to run manage.py syncdb for the new module it still says

Error: No module named my_module

Why, oh why?

EDIT: I didn't created the app with manage.py startapp, but manually created the files. Can this cause the problem?

Upvotes: 0

Views: 3091

Answers (2)

Wooble
Wooble

Reputation: 89897

PATH tells your shell where to find executables; it has nothing to do with Python. PYTHONPATH is a list of directories to search for Python modules. It should be edited to include the directory with my_module.

Upvotes: 2

jbcurtin
jbcurtin

Reputation: 1803

Hard to tell you what the issue is with only that output, however this should solve the problem:

Inside bar.py or bar/__init__.py

import os,sys
sys.path.append(os.path.dirname(__file__))

Now, in other files you can import bar

Upvotes: 0

Related Questions