PYTHONPATH
Richard Laager
rlaager at wiktel.com
Fri Nov 30 14:57:53 UTC 2018
On 11/29/18 8:16 PM, Hal Murray via devel wrote:
> Can somebody give me a lesson in PYTHONPATH?
When doing a module import, Python searches a list of paths. This list
is available in the Python environment as sys.path.
You can see that list as follows (adjust executable names if necessary
for your distro):
Python 2:
python -c 'import sys; print sys.path'
Python 3:
python3 -c 'import sys; print(sys.path)'
When you run ntpsec's ./waf configure, it will print out PYTHONDIR and
PYTHONARCHDIR locations. If those locations are in your sys.path
already, then your current setup is fine.
If those locations are not in your current sys.path, then you can add
those directories to sys.path by setting the environment variable
PYTHONPATH. The contents of the environment PYTHONPATH (which is
colon-separated) are added to sys.path. They are added at index 1 (just
after '', which represents the current working directory), so they will
be search before the default directories.
You can test its effects:
python3 -c 'import sys; print(sys.path)'
PYTHONPATH=foo python3 -c 'import sys; print(sys.path)'
Note that PYTHONDIR and PYTHONARCHDIR may be the same path or different
paths. NTPsec currently installs to (only) PYTHONARCHDIR, but used to
install to (only) PYTHONDIR prior to:
commit 767e48b051179e3ac856223ec9614a0c0131eaab
Author: Ian Bruene <ianbruene at gmail.com>
Date: Mon Aug 13 15:00:39 2018 +0000
Changed to PYTHONARCHDIR.
--
Richard
More information about the devel
mailing list