Matplotlib-cpp:ImportError:没有名为站点的模块

皮埃尔·巴雷特

我正在尝试将matplotlib-cpp用于Visual Studio使用CMake编译的C ++项目。

我使用的python发行版是Anaconda2(今天下载的最新2.7版本)。我删除了计算机上的所有其他python发行版。

我将Anaconda2文件夹的路径添加到了系统AND用户环境变量中。(C:\ Anaconda2 ...)

当使用CMake配置项目时,CMake可以正确找到它,我有:

Found PythonInterp: C:/Anaconda2/python.exe (found suitable version "2.7.16", minimum required is "2.7") 
Found PythonLibs: C:/Anaconda2/libs/python27.lib (found suitable version "2.7.16", minimum required is "2.7") 

该项目可使用VS正确构建(没有构建或链接错误),但是当我运行快速的hello world时,出现错误:

Hello World!
ImportError: No module named site

这是main.cpp:

#include <iostream>
using namespace std;

#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;

int main(int argc, char **argv)
{
    cout << "Hello World!" << endl;

    plt::plot({ 1,3,2,4 });
    plt::show();

    return 0;
}

这是CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)

project(PLT)

set (CMAKE_CXX_FLAGS            "${CMAKE_CXX_FLAGS} -std=c++14")

# main app
add_executable(
    plt
    src/main.cpp
)


# Matplotlib
find_package(PythonInterp   2.7     REQUIRED)
find_package(PythonLibs     2.7     REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(plt ${PYTHON_LIBRARIES})

我在这个论坛上读到这可能是由某些Path问题引起的,但是设置了python目录的路径:

在此处输入图片说明

我正在使用Microsoft Visual Studio 2017与CMake的“ Visual Studio 15 2017 Win64”生成器进行生成,并且通过“ cmd”运行程序,我认为问题在于配置“ cmd”使用的默认python。

我精确地说,我是在Anaconda Python的提示符下尝试过matplotlib的,它正在工作。

关于如何解决这个问题的任何想法?

萨阿德·扎鲁克(Sa'ad Zarook)

通常在PYTHONHOME路径无效或未设置try时发生:

set PYTHONHOME=C:\Python27

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ImportError:没有名为“ matplotlib”的模块

matplotlib-ImportError:没有名为_tkinter的模块

Matplotlib,Jupyter Notebook:ImportError:没有名为Tkinter的模块

ImportError:没有名为matplotlib.pyplot的模块

ImportError:IDLE中没有名为matplotlib的模块

ModuleNotFoundError:没有名为“ matplotlib”的模块

ImportError:没有名为'matplotlib'的模块-使用Anaconda Tensorflow环境

Pylint:如何修复 ModuleNotFoundError:没有名为“matplotlib”的模块

matplotlib错误-没有名为tkinter的模块

ModuleNotFoundError:没有名为“ matplotlib._path”的模块

Zeppelin Notebook 没有名为 pandas 和 matplotlib 的模块

安装后没有名为matplotlib的模块

Jupyter 与 IPython:Matplotlib - 没有名为 Tkinter 的模块

matplotlib错误:即使已安装,也没有名为matplotlib的模块

笔记本中的 matplotlib 错误:没有名为“matplotlib”的模块

lldb:ImportError:没有名为站点的模块

我在使用matplotlib时得到`没有名为_multiarray_umath的模块

jupyter笔记本导入错误:没有名为“ matplotlib”的模块

ModuleNotFoundError:没有名为“ matplotlib”的模块-在Heroku上部署Jupyter项目的问题

ImportError:未安装带有matplotlib的名为matplotlib的模块

ImportError:没有名为gdal的模块

ImportError:没有名为easydict的模块

ImportError:没有名为easydict的模块

ImportError:没有名为“ appdirs”的模块

ImportError:没有名为“ scrapy”的模块

ImportError:没有名为kivy的模块

ImportError:没有名为openerp的模块

ImportError:没有名为“ xlsxwriter”的模块

ImportError:没有名为“编码”的模块