Daniel Daniel - 4 years ago 154
Python Question

django import search path

I'm configuring autocompletion for python and django in vim. One of the problems is that I need to set an environment variable DJANGO_SETTINGS_MODULE=myapp.settings. The django tutorial states that

should be in Python path syntax, e.g.
mysite.settings. Note that the
settings module should be on the
Python import search path.


But if your app isn't in the import search path, how do you make it so that it is?

Answer Source

Three choices.

  1. Set PYTHONPATH environment variable to include your application's directory. Be sure it has an __init__.py file.

  2. Create a .pth file in site-packages to point to your application's directory.

  3. Install your application in site-packages.

These are the three ways of "installing" a Python module. Read about the site module for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download