lava / matplotlib-cpp

Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
MIT License
4.37k stars 1.13k forks source link

Deprecated Functions and Explicit Specialization with Python 3.11 #334

Open aeaotst opened 1 year ago

aeaotst commented 1 year ago

Hello,

I've tried adding matplotlib-cpp to my project as a sanity-checking tool but I've encountered a handful of errors when building. Specifically:

1>C:\Users\user\Source\repos\project\matplotlibcpp.h(174,9): error C4996: 'Py_SetProgramName': deprecated in 3.11 1>C:\Users\user\Source\repos\project\matplotlibcpp.h(182,9): error C4996: 'PySys_SetArgv': deprecated in 3.11 1>C:\Users\user\Source\repos\project\matplotlibcpp.h(354,10): error C2766: explicit specialization; 'matplotlibcpp::detail::select_npy_type<int64_t>' has already been defined 1>C:\Users\user\Source\repos\project\matplotlibcpp.h(345,10): message : see previous definition of 'select_npy_type<__int64>' 1>C:\Users\user\Source\repos\project\matplotlibcpp.h(356,10): error C2766: explicit specialization; 'matplotlibcpp::detail::select_npy_type<uint64_t>' has already been defined 1>C:\Users\user\Source\repos\project\matplotlibcpp.h(349,10): message : see previous definition of 'select_npy_type<unsigned __int64>'

I'm on Windows 10 using Visual Studio 2022 and, as you may have guessed, Python 3.11. Initially tried linking the relevant files manually, then again using vcpkg, with the error unsurprisingly persisting. I've resolved to just push my data into pyplot via fstream since that's probably less hassle than trying to solve this or change Python versions, but I figured I'd raise the issue.

WildRackoon commented 1 year ago

This is probably a duplicate issue of https://github.com/lava/matplotlib-cpp/issues/196

yu113887 commented 1 year ago

I meet same problem. Did you solve this problem?

mithgil commented 2 weeks ago

I also got these issues. The warnings you're encountering are related to deprecated functions in the Python C API. These functions, such as Py_SetProgramName and PySys_SetArgv, are marked as deprecated in Python 3.11 and later versions. And I currently use 3.12 version. The matplotlibcpp library you're using is calling these deprecated functions, which are still valid but marked for removal in future Python versions.

So maybe downgrade your python to <3.10 or wait for the maintainers to update the header file and fix these warnings.