Where the source sys.path comes from

I am trying to figure out where the original sys.path . One of the ubuntu systems suddenly (by which I mean, probably by hand, someone is doing something strange), lost records at the end of the array.

All other hosts: ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']

This host: ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

The path /usr/lib/pymodules/python2.7 is the one I really need. But where does this come from on healthy nodes?

+4
source share
1 answer

It comes from the python-support package, in particular from the installed /usr/lib/python2.7/dist-packages/python-support.pth file.

There should not be any modules installed in this directory manually, and any package installing modules in this directory should depend on the python support package, so you do not need to worry about whether it is in sys.path or not.

+4
source

Source: https://habr.com/ru/post/1384991/


All Articles