Why is there too much on my sys.path?
Question: I am trying to uninstall some package I'm developing (residing in ...plugin-
iqf\test\performance\src), but from within Python shell, I'm still able to
import it.

My `PYTHONPATH` is empty, yet ...

    
    
    Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> for p in sys.path: print p
    ...
    
    c:\Python27\lib\site-packages\setuptools-3.3-py2.7.egg
    c:\Python27\lib\site-packages\catchy-0.1.3-py2.7.egg
    c:\Python27\lib\site-packages\argparse-1.2.1-py2.7.egg
    c:\workspaces\remoteadmin-protocol\implementations\python\src
    c:\workspaces\reslasher\src
    c:\Python27\lib\site-packages\pygtk-2.24.0-py2.7-win32.egg
    c:\workspaces\blizzard\closed-source\plugin-titech\plugin-iqf\test\performance\src
    C:\Windows\system32\python27.zip
    c:\Python27\DLLs
    c:\Python27\lib
    c:\Python27\lib\plat-win
    c:\Python27\lib\lib-tk
    c:\Python27
    c:\Python27\lib\site-packages
    c:\Python27\lib\site-packages\wx-2.8-msw-unicode
    

Where do things like

    
    
    c:\workspaces\remoteadmin-protocol\implementations\python\src
    c:\workspaces\reslasher\src
    

come from?


Answer: Python looks for `.pth` files in four specific directories, formed by
combining `sys.prefix` and `sys.exec_prefix` on the one hand, and the empty
string and (on Windows) `lib/site-packages`. Those `.pth` files can list
additional paths to add to `sys.path`, one per line. See the [`site` module
documentation](https://docs.python.org/2/library/site.html#module-site).

You probably have one or more of those; look for such files in
`c:\Python27\lib\site-packages`, but any files with names matching existing
eggs you did not uninstall, that start with `import` should be left alone;
these generally are hooks to set up namespaced packages.

You could also have a `sitecustomize` module that manipulates `sys.path`. You
can see if you have one by trying to import it:

    
    
    import sitecustomize
    sitecustomize
    

will either fail with an `ImportError` or echo the path.

