This article discoursed by MiniTool Software gathers some information about “Fatal Python error: Py_Initialize: unable to load the file system codec” and “Fatal Python error: Initfsencoding: unable to load the file system codec”. Hope it can help you to some extent!

About “Fatal Python Error Unable to Load the File System Codec”

You may encounter A Fatal Python error: Py_Initialize: unable to load the file system codec problem when you try to make use of Python language for programming on your computer. For example, when you input:

#include <Python.h>

Int main (int, char**)

{

Py_Initialize ();

Py_Finalize ();

Return 0;

]

You may get the output:

Fatal Python error: Py_Initialize: unable to load the file system codec

LookupError: no codec search functions registered: can’t find encoding

As the error message indicates, the issue occurs during initializing Python in your program. The C or C++ compiler can’t load the Python system codec file, which is in charging of encoding and decoding the Python program. The possible causes are listed below.

  • The system cannot locate Python for it isn’t available in system/environment variables.
  • Python hasn’t been installed properly.
  • Two or more Python versions are available.

Next, let’s see the solutions for this error in different system environments.

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.

2. In the new popup named System Properties, click the Environment Variables…

system properties

3. In the next window, if there is any Python path under the User variables for xxx, just click on it and select Delete.

4. Then, choose Path under System variables and click the New button to add the Python path.

change environment variables

In this way, you are able to add the Python path to the environment variables.

Fix “Py_Initialize: Unable to Load the File System Codec” in MacOS

If you come across the same error in Apple Mac operating system (OS), the causes are the same as in the Windows environment. Yet, the solution for the Mac system is a little bit different. In macOS, you should find the .bash_profile or .bashrc file and add this command to the file.

export PYTHONHOME=“/Users/<user>/python3/”

export PYTHONPATH=“${PYTHONHOME}/bin”

Then, you can take advantage of the below command to set the variables.

source .bashrc

Fix “Fatal Python Error Py_Initialize Unable to Load the File System Codec” in Ubuntu/Debian

Also, you have a chance to receive this error code within the Linux-based Ubuntu or Debian operating system for the same reasons. Also, the fix is unlike. There, you have to open the terminal and perform the following command.

$ export PYTHONHOME=/usr/local/lib/python3.5/

$ export PYTHONPATH=/usr/local/lib/pathon3.5/

Google Drive Error Code 5 – Error Loading Python DLL
Google Drive Error Code 5 – Error Loading Python DLL

You may receive the message – error loading Python DLL – when trying to open or sync the Google Drive on your device.

Read More

Fix “Fatal Python Error: Py_Initialize: Unable to Load the File System Codec” in Other OSes

The following are the commands to deal with the error in other operating systems.

# centOS

export PATH=$PATH:/usr/local/bin/python

this command line will append the “/sur/local/bin/python” path in the existing path.

# Anaconda

To handle the problem in the Anaconda system, you need to add the Anaconda path in the path variable.

where conda

where python

when you get the output, add that to the environmental variable of the system following the guide above according to your system.

# Jupyter Notebook

If you get the error, it may be due to that your local computer is not finding the path to Python as the jupyter notebook gets hosted on your local computer. To deal with this situation, you must specify the Python path in environment variables following the above instructions based on your own OS.

[7 Easy Ways] How to Fix File System Error Chromebook Camera?
[7 Easy Ways] How to Fix File System Error Chromebook Camera?

Why does Chromebook file system error camera happen? How to solve the problem? Read this post and pick up the solution that works for you.

Read More

Fix “Fatal Python Error: Initfsencoding: Unable to Load the File System Codec”

Case 1

You may get this error when both Python 3 and Python 2 exist and one of the two fails to start.

#1 File error in Python3 path failed to start Python2

File “E:\Python37\Lib\site.py”, line 177
file =sys.stderr)

SyntaxError: invalid syntax

#2 File error in Python2 path failed to start Python3

Fatal Python error: initfsencoding: Unable to load the file system codec
file “C:\Python27\Lib\encodings\__init__. Py “, line 123
raise CodecRegistryError,\
SyntaxError: invalid syntax
Current thread 0x000004dc (most recent call first):

# Solve the Errors

Those two cases in return the same. The reason is to set the environment variable PYTHONPATH, which is the Python search path. The default module will search from the PYTHONPATH while the environment variable is set to one version of the module paths resulting in another module version loading path error when trying to start, further leading launch failure.

Therefore, the environment variable needs to be configured when the custom module is no longer in C:\Pythonxx\Lib.

How to Fix the VIDEO DXGKRNL FATAL ERROR on Windows 10
How to Fix the VIDEO DXGKRNL FATAL ERROR on Windows 10

If you meet a Blue Screen with stop code VIDEO DXGKRNL FATAL ERROR on Windows 10 and don’t know how to fix it, then you can find methods in this post.

Read More

Case 2

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module
named’encodings ‘ Current thread 0x00001080 (most recent call first)

Tip: The current thread of your error message may be different such as 0x00003c8c.

In Ubuntu operating system, you can downgrade Python using Anaconda or upgrade Anaconda to the latest version.

Also read

The new and powerful Windows 11 will bring you many benefits. At the same time, it will also bring you some unexpected damages such as data loss. Thus, it is strongly recommended that you back up your crucial files before or after upgrading to Win11 with a robust and reliable program like MiniTool ShadowMaker, which will assist you to protect your increasing data automatically on schedules!

MiniTool ShadowMaker TrialClick to Download100%Clean & Safe

Read more

  • linkedin
  • reddit