1.下载Python,配置过程中更换过多种Python版本,由低到高,也尝试过Anaconda,最终均以失败告终,最终选择Python3.9.7。
Python下载链接:Python Releases for Windows | Python.orghttps://www.python.org/downloads/windows/本人下载64位。
3.安装matplotlib和numpy。参考:
(79条消息) Win11 VS2019 C++调用matplotlib_vs如何安装matplotlib_m0_53193782的博客-CSDN博客https://blog.csdn.net/m0_53193782/article/details/1267278044.下载matplotlib。链接为:mirrors / lava / matplotlib-cpp · GitCodehttps://gitcode.net/mirrors/lava/matplotlib-cpp?utm_source=csdn_github_accelerator
5.环境配置过程中出现..\Lib\site-packages目录下没有numpy文件夹(这时候Python自动将numpy安装到其他目录下,默认为..\AppData\Roaming路径下有Python文件夹,里面会用numpy目录),这是由于安装路径有权限限制。建议将Python直接安装到C盘根目录下,解决文件访问权限问题;
6.安装过程中会出现:runtime_error("Error loading module matplotlib!") 问题,后续通过更改python版本号(增大版本号)解决;
7.环境配置完成后,matplotlib只支持Release模式,不支持Debug模式。可通过配置matplotlib.h文件解决,具体可参考:
c++调用matplotlib(二) - 芒果的博客 - 芒果的个人博客 (mangoroom.cn)https://mangoroom.cn/cpp/call-matplotlib-on-cpp-2-html.html8.到此,我的问题解决了!!!Debug模式下画图!!!