git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ModuleNotFoundError: No module named 'encodings'


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