2

I've been doing some work with Python, and I believe my sys.path has "lost" entries. Specifically, I can import no libraries whatsoever (it works if I place them in the folder with the program, but placing it within Python's library directory doesn't work).

Presumably, it has forgotten what folders to look in, and I would like to know how to set sys.path back to it's default values.

Edit: Win7, 32-bit. Yes, I've tried reinstalling (and repairing) Python.

1 Answers1

1

sys.path is read from the environment variable PYTHONPATH. Check to see what the environment variable is, and reset it if needed.

Note that a python script could re-define sys.path.

ernie
  • 6,323
  • 1
    I know how to check sys.path's contents, and I know how to change them. The problem is that I don't know what all of the default values are - I could add entries, sure, but it would just be haphazard guesses. – Kevin Mills Oct 08 '13 at 22:12
  • 1
    If you've clobbered the environment variable PYTHONPATH, and want to restore it, it's probably easiest to just re-install python. If you want people to say what their paths are, providing your OS would be useful, and I guess the could assume you used standard install options . . . – ernie Oct 08 '13 at 22:25
  • When reinstalling, remember to delete %PYTHONPATH% first. – Doktoro Reichard Oct 08 '13 at 22:34
  • 1
    sys.path != PYTHONPATH – mrgloom Jun 24 '19 at 16:36