1If you are trying to debug something like:
2  ImportError: No module named ntp
3you have come to the right place.
4
5The default location where we install our python libraries is
6  /usr/local/lib/pythonX.Y/site-packages/
7where X and Y are the python version numbers.
8
9Unfortunately, that's not on the default search path of several
10OSes/distros, in particular Fedora and NetBSD.
11
12
13Python has a search path that is used to find library modules when
14you import them.  You can see your search path with:
15  python2 -c "import sys; print sys.path"
16or
17  python3 -c "import sys; print(sys.path)"
18
19Info on Python's search path:
20  https://docs.python.org/2/tutorial/modules.html
21or
22  https://docs.python.org/3/tutorial/modules.html
23
24
25
26There are several ways to make things work.
27
281: You can modify the location where waf will install the libraries.
29For NetBSD, something like this should work:
30  ./waf configure \
31    --pythondir=/usr/pkg/lib/python2.7/site-packages \
32    --pythonarchdir=/usr/pkg/lib/python2.7/site-packages \
33    ...
34You need to specify it at configure time.  Install time is too late.
35
36
372: You can setup your PYTHONPATH with something like this:
38  export PYTHONPATH=/usr/local/lib/python2.7/site-packages
39For bash, you can add that line to your .bashrc or the system /etc/bashrc
40If you don't put it in the system file, all users will have to do this,
41including root if root uses any ntp scripts.
42
43
443: You can add to the default search path by setting up a .pth file
45with something like this:
46  echo /usr/local/lib/python2.7/site-packages > \
47    /usr/lib/python2.7/site-packages/ntpsec.pth
48This works for all users, including root.
49Note that the pth file must be on the default Python search path.
50
51
52OTOH if you run into something like:
53    Traceback (most recent call last):
54      File "/usr/bin/ntpdig", line 419, in <module>
55        timeout=timeout)
56      File "/usr/bin/ntpdig", line 109, in queryhost
57        keyid, keytype, passwd)
58      File "/usr/lib/python3/dist-packages/ntp/packet.py", line 1747, in compute_mac
59        if not ntp.ntpc.checkname(keytype):
60    AttributeError: module 'ntp.ntpc' has no attribute 'checkname'
61
62Then you probably want to either uninstall the previous Python extension, or
63install one after 1.1.9 (798b93) by adding the '--enable-pylib ext' option
64without quotes.
65
66OTOH if you are running into something like:
67    Traceback (most recent call last):
68    File "/usr/bin/ntpdig", line 19, in <module>
69        import ntp.packet
70    File "/usr/lib/python3/dist-packages/ntp/packet.py", line 219, in <module>
71        import ntp.ntpc
72    File "/usr/lib/python3/dist-packages/ntp/ntpc.py", line 52, in <module>
73        _ntpc = _importado()
74    File "/usr/lib/python3/dist-packages/ntp/ntpc.py", line 38, in _importado
75        return _dlo(ntpc_paths)
76    File "/usr/lib/python3/dist-packages/ntp/ntpc.py", line 49, in _dlo
77        raise OSError("Can't find %s library" % LIB)
78    OSError: Can't find ntpc library
79
80That means is that ntpc.py looked for libnptc.so in the usual places and could
81not find it.  If it is being installed to the wrong location on your platform,
82you can correct the install location using: waf configure --libdir=  If you
83are intentionally installing to a non-default location, you can modify the
84dynamic linker's search path globally (e.g. /etc/ld.so.conf or
85/etc/ld.so.conf.d/) or in your environment (e.g. LD_LIBRARY_PATH).
86
87On some platforms, it is necessary to run ldconfig after installing libraries.
88This is normally done by the waf install step, but it may have failed.  When
89using a temporary --destdir (e.g. as part of package builds), ldconfig must be
90run manually after the library is installed to its final location.
91