This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients methane, ncoghlan, pablogsal, steve.dower, vstinner
Date 2019-09-20.16:44:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When Python path configuration is not properly configured, Python fails with an error looking like:
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007ff0065b2740 (most recent call first):
<no Python frame>

This error is very common and hard to debug. It can happen in various cases for various reasons:

* Python is embedded in an application
* PYTHONPATH and/or PYTHONHOME environment variable is set
* pyenv.cfg configuration for virtual environment
* Local .py files which override the standard library

A few examples:

* bpo-38234: Py_SetPath() regression in Python 3.8 which impacts PyInstaller
* virtual env
* "" file in the current directory
* embedded Python
* Python 3 installed by Anaconda which uses Python 2.7 stdlib because of PYTHONPATH
* Python embedded in "gns3"
* venv
* another random error

Attached PR dumps the Python path configuration if importing the Python codec of the filesystem encoding fails. In the Python initialization, it's the first import which is done.
Date User Action Args
2019-09-20 16:44:55vstinnersetrecipients: + vstinner, ncoghlan, methane, steve.dower, pablogsal
2019-09-20 16:44:55vstinnersetmessageid: <>
2019-09-20 16:44:55vstinnerlinkissue38236 messages
2019-09-20 16:44:55vstinnercreate