Python libs on Debian/Raspbian

Richard Laager rlaager at
Tue Dec 19 06:26:47 UTC 2017

On 12/18/2017 09:10 PM, Gary E. Miller via devel wrote:
> On Fri, 8 Dec 2017 22:34:46 -0600
> Richard Laager <rlaager at> wrote:
>> When you say PYTHONPATH, do you mean:
>> 1) "a custom directory set in the environment variable PYTHONPATH"
>> or
>> 2) A directory that python searches.
> Hmm... I think those are the same.

Okay, that's what I thought you thought. This may be leading to some
confusion for you, and it's definitely making your arguments hard to
follow for me.

They're definitely NOT the same.

> How do you think they differ?

As I said:
>> #1 is PYTHONPATH. #2 is sys.path, not PYTHONPATH.

> Explain?

As I wrote (to you, CC devel) on 2017-12-12 in the other thread:

sys.path is the path that is actually searched. sys.path is built from a
set of installation-dependent defaults, plus the value of the PYTHONPATH
environment variable. That is, PYTHONPATH is *added* to the default
sys.path. Contrast this with PATH, where the environment variable *is*
the list to be searched.

For example, try these on your system:

$ python -c 'import sys; print sys.path'

$ PYTHONPATH=/opt/foo/site-packages \
  python -c 'import sys; print sys.path'

You will see that PYTHONPATH *adds* to sys.path. Paths in PYTHONPATH are
added high in the list (second, after '' which is the current
directory), so paths in PYTHONPATH are searched before the
installation-dependent defaults.

.pth files are another way to *add* to sys.path.

See also the official docs:

> Uhmmm.. well, the standard is that by default user installed packeges
> go in /usr/local, and the standard is taht PYTHONPATH should not
> include /usr/local.

I'd rephrase this as follows:

  The FHS says that user installed packages go in /usr/local. It is our
  understanding that upstream Python, when configured to install in
  /usr, does not include anything from /usr/local in sys.path, though
  some distros (e.g. Debian) patch this.

Given that, absent distro patching, it is *impossible* to both honor
--prefix=/usr/local (i.e. never write anything outside of /usr/local)
and have the modules loaded by default, without the user modifying
sys.path (by either setting PYTHONPATH or creating a .pth file).

The suggestions on the other thread are to: A) warn the user, suggesting
they create a .pth file, or B) create the .pth file for them, violating
prefix, but minimally.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the devel mailing list