I tried to run a .py file by typing python twitterstream.py > output.txt in the command prompt of windows 10. It then said
fatal python error: Py_Initialize: unable to load the file system codec
File "C:\Python27\Lib\encodings\__init__.py", line 123 raise CodecRegistryError,\
SyntaxError: invalid syntax
From what I saw through a google search, the solution may be to change the PYTHONPATH env variable. However, I had PYTHONPATH set to C:\Python27 for both the user and system variables, but I still get the same error in the command prompt
I also read http://bugs.python.org/issue11288, and tried to change all PYTHONPATH system variable which originally pointed to C:\Python27 and changed it to C:\Python34 but that didn't solve the problem
I then followed https://docs.python.org/3/using/windows.html#python-launcher-for-windows, but when I type py it says Python 2.7.9 .., but for py -3 I get a popup saying python.exe has stopped working and
fatal python error: Py_Initialize: unable to load the file system codec
File "C:\Python27\Lib\encodings\__init__.py", line 123 raise CodecRegistryError,\
SyntaxError: invalid syntax
also, py hello.py says from python 2.7.9 ..., but changing #! python to #! python3 gives the same error I said before
Even if I set PATH AND PYTHONPATH user variables to C:\Python34;C:\Python27;C:\Python27\Scripts;C:\Python34\Scripts, along with the PythonPath system variable to C:\Python34;C:\Python27;C:\Python27\Scripts;C:\Python34\Scripts, but the error was the same as before
PYTHONHOMEset toC:\Python27. Generally there's no reason to set eitherPYTHONPATHorPYTHONHOME, not with the official Python distributions. Unset these variables. There are better ways to managesys.pathfor a particular installation that don't cause such conflicts.PYTHONHOMEas an environment variable. And when you say unset, you mean delete them? When I tried that onPYTHONPATH, I got the same error as beforeset "PYTHONHOME=C:\Python27". This overrides Python's defaultsys.prefix, by which it finds its standard library. Python 3 obviously can't use Python 2's standard library. In the command prompt enterset PYTHON. Does this listPYTHONHOMEor justPYTHONPATH? If it's justPYTHONPATH, that should not cause that error when runningpy -3. Something else is wrong.set PYTHONit saysEnvironment variable PYTHON not definedPYTHONHOMEnorPYTHONPATHis set. In that command prompt do you get the error forpy -3?