用于c ++的matplotlib给出此错误:'PyObject_CallObject':函数未使用3个参数

我有microsoft visual studio 2019并使用nuget为它安装了matplotlib,但是当我要构建此代码时:

#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
int main() {
    plt::plot({ 1,3,2,4 });
    plt::show();
}

出现此错误:'PyObject_CallObject': function does not take 3 arguments

这是构建输出:

1>------ Build started: Project: ConsoleApplication3,Configuration: Debug Win32 ------
1>ConsoleApplication3.cpp
1>C:\Users\matthijs\source\repos\ConsoleApplication3\packages\matplotlib-cpp.1.1.0.92\include\matplotlibcpp\imshow.h(58,21): error C2660: 'PyObject_CallObject': function does not take 3 arguments
1>C:\Users\matthijs\source\repos\ConsoleApplication3\packages\matplotlib-cpp.1.1.0.92\sandbox\include\abstract.h(363,29): message : see declaration of 'PyObject_CallObject'
1>C:\Users\matthijs\source\repos\ConsoleApplication3\packages\matplotlib-cpp.1.1.0.92\include\matplotlibcpp\imshow.h(58,40): message : 'PyObject_CallObject': function declaration must be available as none of the arguments depend on a template parameter
1>Done building project "ConsoleApplication3.vcxproj" -- FAILED.
========== Build: 0 succeeded,1 failed,0 up-to-date,0 skipped ==========

和完整错误:


Severity    Code    Description Project File    Line    Suppression State   Suppression State
Error   C2660   'PyObject_CallObject': function does not take 3 arguments   ConsoleApplication3 C:\Users\matthijs\source\repos\ConsoleApplication3\packages\matplotlib-cpp.1.1.0.92\include\matplotlibcpp\imshow.h  58      

该如何解决? 我用nuget安装了matplotlib的最新版本

错误发生在这里: PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_imshow,plot_args,kwargs); 我有一台Windows 10笔记本电脑,并且使用python 3.7

lqn1987521 回答:用于c ++的matplotlib给出此错误:'PyObject_CallObject':函数未使用3个参数

如错误所述,“ PyObject_CallObject”不带3个参数。 看着some docs I found on a quick google,看起来您的args(plot_args,kwargs)需要放在一个元组中-它们都必须在PyObject_CallObject的一个arg中。

本文链接:https://www.f2er.com/3167282.html

大家都在问