【发布时间】:2014-02-06 06:12:29
【问题描述】:
我有以下代码
#include <boost/python.hpp>
int main()
{
Py_Initialize();
namespace python = boost::python;
try {
python::object main = python::import("sample");
} catch(...) {
PyErr_Print();
PyErr_Clear();
}
}
我收到以下错误:
ImportError: No module named sample
我将我的 sample.py 放在与该程序相同的目录中。
【问题讨论】:
-
调试导入问题时,将
PYTHONVERBOSE环境变量设置为2会很有帮助。这将导致 Python 打印 python 尝试导入文件的位置。
标签: c++ boost-python