On Mon, Jun 3, 2013 at 3:41 AM, Jim Mooney <cybervigila...@gmail.com> wrote: > Ah, useful. A lot more than is on windows path and PYTHONPATH > obviously gets snuck in there. Sure enough, I queried sys.path and > there's a Lot more in there.
The path for the script comes first, followed by the contents of the PYTHONPATH environment variable, if present. Next it adds the optional zip library, additional paths from subkeys of PythonPath in HKCU/HKLM, the core path string (expanded for sys.prefix / PYTHONHOME) that I already mentioned, and also the path of the executable (e.g. python.exe). Next, site.py is imported (if you didn't use the -S option), which adds lib\site-packages and paths from .pth files if they exist. If you've installed a package with --user, it will also add "%AppData%\Python\Python27\site-packages". Finally, it tries to import sitecustomize.py and usercustomize.py. > If I dump a package (not sure how to do that beyond just deleting it, > but I've tried some bad ones, so I'd like to) how do I remove it from > sys.path, or do I need to? An exe/msi installer should clean up after itself when you uninstall. With pip, you can "pip uninstall". With easy_install, use "-mxN PackageName" (that should remove scripts and clear the package from setuptools.pth), and then manually delete the directory. As to any .pth files left behind, the directories listed in them won't be added to sys.path if they no longer exist. So leaving them around only costs a few milliseconds of startup time. If for some reason a package stored paths in a subkey of PythonPath, you'll have to remove the subkey to keep it from being added to sys.path -- but I haven't actually seen a package use this option. .pth files are simpler and cross-platform. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor