最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

运维笔记admin4浏览0评论

记录备忘.

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();

 

发布评论

评论列表(0)

  1. 暂无评论