I want to add a specific library path only to python2. After adding export PYTHONPATH=\"/path/to/lib/\" to my .bashrc, however, executing python3 gets
You can create a configuration file mymodule.pth under lib/site-packages (on Windows) or lib/pythonX.Y/site-packages (on Unix and Macintosh), then add one line containing the directory to add to python path.
From docs.python2 and docs.python3:
A path configuration file is a file whose name has the form
name.pthand exists in one of the four directories mentioned above; its contents are additional items (one per line) to be added tosys.path. Non-existing items are never added tosys.path, and no check is made that the item refers to a directory rather than a file. No item is added tosys.pathmore than once. Blank lines and lines beginning with # are skipped. Lines starting withimport(followed by space or tab) are executed.