I'm installing Python on my Windows 10 laptop, and when I try to run it I get this:
Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' Current thread 0x0000037c (most recent call first):
Fix “Fatal Python Error: Unable to Load the File System Codec” in Windows 11/10. According to the possible reasons, you need to properly install the Python as well as set the Python path in system/environment variables. 1. Search for “edit the system environment variables” in Windows Search and open the matched result.
I ran into this same issue on Windows 10. Here's how I fixed it:
C:\Python37-32\Scripts\
and C:\Python37-32\
Then click 'OK' (Make sure to check that these path values correspond to the location and version of your Python install.)PYTHONHOME
variable and make sure that it is also set to C:\Python37-32
This issue has been addressed here in this thread. Apparently, running the Python setup as an administrator and/or correctly setting the environment variables solved this issue.
First, don't forget to select "Add Python 3.x to PATH" before you click on Install now and reboot after installation so that the new path is taken into account by Windows.
Second, I had the the same problem with Python 3 on Windows 7 and 64-bit and I got rid of it by deleting PYTHONPATH and PYTHONHOME from Windows 7 system environment variables, because I had a previous installation of Python 2 and those paths were pointing to my the Python 2 directory. I had to simply to delete the PYTHONPATH and PYTHONHOME variables.
I had the same problem (I use a Mac, but I don't think it makes any difference in this problem) and it was coming from the difference between the selected Python interpreter path and the current working directory in spyder.
I use virtual environments in Python to avoid version conflicts of installed modules between various projects (I believe it is a good practice). This leads me to configure the interpreter path in spyder by accessing:
preferences > python interpreter > use the following interpreter
The problem comes when I launch spyder from a different path. I get exactly the same error as Milo's. To solve it I see two options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With