2

I am running a script that explicitly sets the PYTHONPATH to avoid naming collisions. However, even if I say os.environ['PYTHONPATH'] = '', it looks as though the system is still able to find my old path that "lives" outside the script.

How is my system able to see the old PYTHONPATH even after I explicitly set it to a new one?

Matt Norris
  • 8,596
  • 14
  • 59
  • 90

1 Answers1

4

The PYTHONPATH environment variable is parsed at startup and inserted into sys.path. If you need to adjust the path from within your Python code, manipulate sys.path, not PYTHONPATH.

Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299