admin管理员组

文章数量:1567572

记录备忘.

1.完整报错信息

Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f5ab301f6c0 (most recent call first):

2.报错原因

场景是C++调用python时,找不到python解释器。

3.解决办法

在init之前添加解释器位置说明。

Py_SetPythonHome(L"/home/zxq/anaconda3/envs/onnx");

# 再去初始化
Py_Initialize();

printf("Python init \n");


Py_Finalize();

 

本文标签: PYTHONHOMESettingexecprefixprefix