0

Fresh install of Python 3.6 on Windows 7.

I am presented with the following error when attempting to open Python 3.6:

Fatal Python error: Py_Initialise: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000252c (most recent call first):

I've tried:

  • Setting the Path, PYTHONPATH, and PYTHONHOME variables to the directory where Python 3.6 is installed, but this has NOT resolved the issue, despite it being presented as a solution in other threads.
  • Reinstalling with the 32 bit version and the same error occurs.
  • Running with administrator privileges and the same error occurs.
  • Copying the Python36 folder to my user folder, setting the Path, PYTHONPATH, and PYTHONHOME variables to this new folder but the same error occurs.
  • Installing Python 3.6 for all users and just for my user, but the same error occurs.
asked Oct 11, 2017 at 14:37
3
  • Setting PYTHONPATH and PYTHONHOME is not the solution and actually is generally the problem. PYTHONPATH can be used -- carefully -- to add directories to sys.path, as long as you're aware it's affecting sys.path for every installed interpreter and as long as you never include the installation directory or the "Lib" subdirectory or anything under it. PYTHONHOME is only required in special cases. It should never be used for a standard Python installation from python.org. Commented Oct 11, 2017 at 14:48
  • In a command prompt, check where python to ensure you're running the right version, and check set PYTHON to ensure that no Python-specific environment variables are set; if they are, unset them, e.g. run set PYTHONHOME= to clear that variable in the current shell. Commented Oct 11, 2017 at 14:51
  • Is there an encodings folder (containing a __init.py__ file) in your "%PYTHON36_INSTALL_DIR%\Lib" folder? Commented Oct 11, 2017 at 16:38

2 Answers 2

1

Download this file and place under Lib folder in python directory

https://github.com/python/cpython/blob/3.6/Lib/codecs.py

answered Oct 11, 2017 at 14:41
Sign up to request clarification or add additional context in comments.

Comments

1

Thank you, erkysun.

Removing all Python related directory paths from my environment Path, PYTHONPATH, and PYTHONHOME variables solved the issues I was experiencing.

For the benefit of anyone else experiencing this issue in the future, I removed these directory paths by:

  1. Typing 'env' into my search Windows 7 search bar, and opening 'Edit the system environment variables'
  2. Clicking the 'Environment Variables...' button in the bottom right hand corner of the dialogue box which appears
  3. Locating Path, PYTHONPATH, and PYTHONHOME and making the appropriate deletions.

Thanks for your help everyone.

answered Oct 13, 2017 at 13:58

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.