I am trying to install Python for the first time. I downloaded the following installer from the Python website: Python 2.7.1 Windows Installer (Windows binary -- does not include source). I then ran the installer, selected 'All Users' and all was fine. I installed Python into the default location:
C:\Python27
Next, to test that Python was installed correctly, I navigated to my Python Directory, and ran the "python" command in the windows cmd prompt. It returns me the following error:
ImportError: No module named site
When I do 'python -v' I get the following:
#installing zipimport hook
#installed zipimport hook
import zipimport # builtin
#ImportError: No module named site
#clear builtin._
#clear sys.path
#clear sys.argv
#clear sys.ps1
#clear sys.ps2
#clear sys.exitfunc
#clear sys.exc_type
#clear sys.exc_value
#clear sys.exc_traceback
#clear sys.last_type
#clear sys.last_value
#clear sys.last_traceback
#clear sys.path_hooks
#clear sys.path_importer_cache
#clear sys.meta_path
#clear sys.flags
#clear sys.float_info
#restore sys.stdin
#restore sys.stdout
#restore sys.stderr
#cleanup main
#cleanup
[1] zipimport
#cleanup[1
] signal
#cleanup
[1] exceptions
#cleanup[1
] _warnings
#cleanup sys
#cleanup builtin
#cleanup ints: 6 unfreed ints
#cleanup floats
When I do dir C:\Python27\Lib\site.py*
I get the following:
C:\Users\Mimminito>dir C:\Python27\Lib\site.py*
Volume in drive C has no label.
Volume Serial Number is DAB9-A863Directory of C:\Python27\Lib
13/11/2010 20:08 20,389 site.py
1 File(s) 20,389 bytes
0 Dir(s) 694,910,976 bytes free
Any ideas?
Make sure your PYTHONHOME environment variable is set correctly. You will receive this error if PYTHONHOME is pointing to invalid location or to another Python installation you are trying to run.
Try this:
Use
to set this permanently for subsequent command prompts
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
export
ing PYTHONHOME=/usr/ and PYTHONPATH=/usr/lib/python2.7I have an application which relies heavily on Python and have kept up-to-date with python 2.7.x as new versions are released. Everthing has been fine until 2.7.11 when I got the same "
No module named site
" error. I've set PYTHONHOME toc:\Python27
and it's working. But the mystery remains why this is now needed when it wasn't with previous releases. And, if it is needed, why doesn't the installer set this var?Install yaml from the PyYAML home pagee: http://www.pyyaml.org/wiki/PyYAML
Select the appropriate version for your OS and Python.
For me it happened because I had 2 versions of python installed - python 27 and python 3.3. Both these folder had path variable set, and hence there was this issue. To fix, this, I moved python27 to temp folder, as I was ok with python 3.3. So do check environment variables like PATH,PYTHONHOME as it may be a issue. Thanks.
Quick solution: set PYTHONHOME and PYTHONPATH and include PYTHONHOME on PATH
For example if you installed to c:\Python27
Make sure you don't have a trailing '\' on the PYTHON* vars, this seems to break it aswel.