[Tutor] how to permanently add a module path
chris.arndt at web.de
Fri Dec 22 17:49:19 CET 2006
shawn bright schrieb:
> i am on ubuntu and there is no /etc/profile.d directory
> i put this in the /etc/environment file
> export PYTHONPATH
> but it doesn't seem to be working.
> There is no master python config file somewhere where all these are listed ?
> i wonder becuase i add modules via apt, and they are put where they need
> to be.
Ok, I see, you're trying to add you module in the standard site modules path
(/usr/lib/pythonX.Y/site-packages on Unices). This is an entirely different matter.
You have two possibilities:
1) Turn your module directory into a paackage by adding a '__init__.py' file to
it. This file may be empty. You can then iumport from your module like this:
from pivotrac import mymodule
For more information on Python module packages, see here:
2) You can add a .pth file to the site-packages directory that points to your
module directory. E.g. ass a file pivotrac.pth to
/usr/lib/python2.4/site-packages/ that just contains one line:
For more information about .pth files, see here:
With both methods you don't need to change PYTHONPATH at all.
P.S. Please don't answer privately to somebody writing on the list, unless
asked to do so. Reply to the list instead.
More information about the Tutor