使用“#include <boost\python.hpp>”导入时提升 Python "cannot open source file 'pyconfig.h'"

Boost Python "cannot open source file 'pyconfig.h'" when importing using "#include <boost\python.hpp>"

我正在尝试将 Boost Python 用于一个项目。我已经在 Windows 10 上下载并构建了 1.70 版,我正在使用 Visual Studio 代码。尝试使用以下行将 boost 导入我的 C++ 项目时:

#include <boost\python.hpp>

,我收到以下错误:

cannot open source file "pyconfig.h" (dependency of "boost\python.hpp")

我调查了类似的问题,发现的主要解决方案是编辑 user-config.jam 以包含我的 python 安装位置。我这样做了,user-config.jam 中的行如下所示:

using python : 3.7 : C:\Users\broke\AppData\Local\Programs\Python\Python37 ;

添加此行后,我重建了 Boost Python。这对解决问题没有任何帮助。我将不胜感激在这件事上的帮助。谢谢。

您需要确保 python/include 文件夹已添加到您的包含中。 C:\Python\Python37\include 我 windows。您还需要 link python 库。