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
If you don't want to bother with moving/adding documents in lib/site-packages
, try adding two lines of code in the python2.7 script you would like to run (below.)
import sys
sys.path = [p for p in sys.path if p.startswith(r'C:\Python27')]
This way, PYTHONPATH will be updated (ignore all python3.x packages) every time you run your code.