项目场景:
使用python sklearn训练模型,C++ boost加载模型脚本文件。
问题描述
使用visual studio 2019,配置好boost和python。
包含目录配置:
库目录配置:
测试后发现程序报错:
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’
原因分析:
原因是python的环境变量没有配置好。
解决方案:
根据提示:
可知:PYTHONHOME和PYTHONPATH没有配置。
打开系统属性——>环境变量——>系统变量:
建立PYTHONHOME和PYTHONPATH,路径名即为python的安装路径。
注意:如果python是基于Anaconda安装的,要取到envs下的各个python版本