How to manage python3 sys.path on Linux

35 Views Asked by At

I run a cluster of 8 machines (not identical) that all run Ubuntu. Not always the exact same version, but close. I'm working on a couple of python modules and am puzzled about sys.path and in general how to best publish the modules so that they are out of the way, but accessable.

I see a number of questions about this, but they are mostly quite old, some are for python2, many seem specific to a different OS. I've tried some answers, but none did any good in my situation. Some answers I didn't try because I didn't understand them. I'm only interested in python3 on Debian-based Linux (with Fedora a possible outlier).

The bottom line is I cannot seem to change site.path from outside the process I'm starting, but that's what I need to do.

What I've tried:

  • Sneaky -- and a solution I really don't like -- is to put my module in one of the directoreis already on the path. But they are all named some variation on dist-packages and doing it that way just seems wrong. But it makes the modules accessable.

  • Set $PYTHONPATH in the shell before launching python. No joy.

I'd prefer to have something I can do to a dotfile like .bashrc, and a directory that I can drop my modules into (named site-packages or some such.) So what can I do to get python3 to recognize and search a site-packages directory?

0

There are 0 best solutions below