一、vscode下c++使用matplotlib-cpp的环境配置
我配置环境主要借鉴于这位博主的文章
vscode下c++使用matplotlib-cpp的环境配置教程_matplotlibcpp.h:353:37: error: expected ',' before-CSDN博客
二、报错信息
2.1 Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding,按照网上的教程修改系统环境变量,PYTHONHOME和PYTHONPATH的为anaconda的目录,但是gbd调试,会直接修改PYTHONHOME的值,变成mingw/opt
解决方法:除了在系统环境变量中添加PYTHONHOME和PYTHONPATH以外,在launch.json中添加"environment": [{"name": "PYTHONHOME", "value": "D:\\software\\python3.9.12"}],
2.2 ModuleNotFoundError: No module named 'numpy' ModuleNotFoundError: No module named 'matplotlib' terminate called after throwing an instance of 'std::runtime_error' what(): Error loading module matplotlib!
解决方法:在python中用pip安装numpy和matplotlib即可
命令行中运行pip3 install --user numpy matplotlib