2

I am very new to python, I have installed Python 3.6 on my Windows 10 machine ( and I believe it has version 2.7 installed ). The installation was ok but when I try to start up it gives me error as shown below

Fatal Python error: Py_Initialize: unable to load the file system codec
  File "C:\csvn\Python25\\lib\encodings\__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax

Current thread 0x00002c78 (most recent call first):

Please someone would help me to identify this error and how to fix it. Thank you so much in advance for any help.

Prin Puyakul
  • 147
  • 2
  • 13
  • The error you are getting is caused by importing a Python 2.5 version of `encodings` in Python 3.6. That comma in the `raise` statement that is causing the syntax error is valid in Python 2 but not in Python 3. You can even see the version number in the path mentioned in the message. – BoarGules Dec 07 '17 at 13:02
  • For a vanilla installation you should have *neither* `PYTHONPATH` nor `PYTHONHOME` set in your environment. In a command prompt, enter `set PYTHON` to confirm that neither is set. If you use `PYTHONPATH` to add custom library directories, it should *never* include Python's installation directory or standard library directories. – Eryk Sun Dec 07 '17 at 21:49

2 Answers2

1

The error can be resolved by adding an environment variable "PYTHONPATH" which point to the installation location of Python.

Refer to the following link,

Py_Initialize fails - unable to load the file system codec

AzizStark
  • 1,390
  • 1
  • 17
  • 27
  • No, this error is almost always caused by needlessly defining `PYTHONHOME` (which should only be set temporarily in particular embedding and non-standard distribution scenarios) or adding standard directories to `PYTHONPATH`. Don't compound a mistake with more mistakes. – Eryk Sun Dec 08 '17 at 00:45
0

It may be because you have different versions of Python installed, so when you try to use the newest installed, it may be use the old interpreter instead, to solve the problem you absolutely need to change the PYTHONPATH.

Changing PYTHONPATH in shell [closed]

Paradisee
  • 29
  • 8
  • Thanks for both answers, But I still confuse and can't find the file that I need to edit to change the PYTHONPATH could you please help me locate the file. Thanks in advance – Prin Puyakul Dec 07 '17 at 12:12
  • I'm pretty much sure i answered your question already. Just follow the link i mentioned and you're done. Here you got another way to solve this. [link] (https://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7) – Paradisee Dec 07 '17 at 13:02