ModuleNotFoundError: No module named 'encodings'

Thomas Jollans tjol at tjol.eu
Fri Sep 7 11:46:03 EDT 2018


On 2018-09-07 17:13, Jason Qian via Python-list wrote:
> Thanks Thomas,
> 
> You are right, this seems the Python home configuration issue.
> 
> One more question.
> 
> Is there a way I can catch the error ( Fatal Python error: initfsencoding:
> ..) as exception in the c code ?

It's a fatal error, which means it aborts.

As I'm sure you know, C doesn't have exceptions. You might be able to
handle SIGABRT, I'm not sure.

> 
> try{
>     Py_Initialize();
> }catch(xxx)
> {
> 
> }
> 
> 
> Thanks
> 
> 
> 
> On Thu, Sep 6, 2018 at 5:29 PM, Thomas Jollans <tjol at tjol.eu> wrote:
> 
>> On 09/06/2018 09:46 PM, Jason Qian via Python-list wrote:
>>
>>> Hi
>>>
>>> Need some help.
>>>
>>> I have a C++ application that invokes Python.
>>>
>>> ...
>>> Py_SetPythonHome("python_path");
>>>
>>
>> This isn't actually a line in your code, is it? For one thing,
>> Py_SetPythonHome expects a wchar_t*...
>>
>> Py_Initialize();
>>>
>>> This works fine on Python 3.6.4 version, but got errors on Python 3.7.0
>>> when calling Py_Initialize(),
>>>
>>> Fatal Python error: initfsencoding: unable to load the file system codec
>>> ModuleNotFoundError: No module named 'encodings'
>>>
>>
>> So, Python can't find a core module. This either means your Python 3.7
>> build is broken, or it doesn't know where to look. Perhaps whatever it is
>> you're actually passing to Py_SetPythonHome needs to be changed to point to
>> the right place? (i.e. maybe you're giving it the location of the Python
>> 3.6 library rather than the Python 3.7 one)
>>
>> -- Thomas
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>




More information about the Python-list mailing list