- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经看到 mac OS 用户发生了这个问题,但我目前在 windows10 上,我不知道如何解决这个问题。
我正在使用 Visual Studio 2017 和 Python 2.7。但是,我的 PC 中也有 Python 3.7 和 Anaconda,所以我希望这不会弄乱正确库的链接器。
我正在使用这个库 https://github.com/lava/matplotlib-cpp
在 matplotlibcpp.h 中,第 137 行。我遇到了一个异常:
Excepción producida en 0x00007FFFCF28E78A (ntdll.dll) en ConsoleApplication2.exe: 0xC0000008: An invalid handle was specified.
PyObject* matplotlibname = PyString_FromString("matplotlib");
PyObject* pyplotname = PyString_FromString("matplotlib.pyplot");
PyObject* cmname = PyString_FromString("matplotlib.cm");
PyObject* pylabname = PyString_FromString("pylab");
if (!pyplotname || !pylabname || !matplotlibname || !cmname) {
throw std::runtime_error("couldnt create string");
}
PyObject* matplotlib = PyImport_Import(matplotlibname);
Py_DECREF(matplotlibname);
if (!matplotlib) { throw std::runtime_error("Error loading module matplotlib!"); }
// matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
// or matplotlib.backends is imported for the first time
if (!s_backend.empty()) {
PyObject_CallMethod(matplotlib, const_cast<char*>("use"), const_cast<char*>("s"), s_backend.c_str());
}
PyObject* pymod = PyImport_Import(pyplotname);
Py_DECREF(pyplotname);
if (!pymod) { throw std::runtime_error("Error loading module matplotlib.pyplot!"); }
import matplotlib.pyplot
在终端(使用python2.7),它完美地工作:
最佳答案
我有同样的错误。我正在使用 anakonda python 发行版。
我通过重新安装 matplotlib 修复了错误。
pip 卸载 matplotlib
点安装 matplotlib
确保在用户级别定义了以下环境变量。
python 之家 C:\Anaconda3
python 路径 C:\Anaconda3
QT_QPA_PLATFORM_PLUGIN_PATH %PYTHONHOME%库/插件/平台
关于python - Matplotlibcpp - 导入 Python 模块的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54982492/
我已经看到 mac OS 用户发生了这个问题,但我目前在 windows10 上,我不知道如何解决这个问题。 我正在使用 Visual Studio 2017 和 Python 2.7。但是,我的 P
我想为 C++ 程序安装绘图功能。我选择 matplotlibcpp 是因为它的简单性和在线评论。但是,我无法制作情节并出现许多神秘错误(我是 C++ 的新手)。更新 VS 2019 的包含路径后,我
我是一名优秀的程序员,十分优秀!