python – ImportError: No module named site on Windows

python – ImportError: No module named site on Windows

Ive been looking into this problem for myself for almost a day and finally had a breakthrough. Try this:

  1. Setting the PYTHONPATH / PYTHONHOME variables

    Right click the Computer icon in the start menu, go to properties.
    On the left tab, go to Advanced system settings. In the window that comes up, go to the Advanced tab, then at the bottom click Environment Variables. Click in the list of user variables and start typing Python, and repeat for System variables, just to make certain that you dont have mis-set variables for PYTHONPATH or PYTHONHOME. Next, add new variables (I did in System rather than User, although it may work for User too): PYTHONPATH, set to C:Python27Lib. PYTHONHOME, set to C:Python27.

Hope this helps!

Quick solution: set PYTHONHOME and PYTHONPATH and include PYTHONHOME on PATH

For example if you installed to c:Python27

set PYTHONHOME=c:Python27
set PYTHONPATH=c:Python27Lib
set PATH=%PYTHONHOME%;%PATH%

Make sure you dont have a trailing on the PYTHON* vars, this seems to break it aswel.

python – ImportError: No module named site on Windows

I was having this issue after installing both Windows Python and Cygwin Python, and trying to run Cygwin Python from Cygwin. I solved it by exporting PYTHONHOME=/usr/ and PYTHONPATH=/usr/lib/python2.7

Leave a Reply

Your email address will not be published. Required fields are marked *