我在一个名为cpp_examples的文件夹中有以下文件。在#include
#include
const std::string hello() {
return std::string("hello, zoo");
}
BOOST_PYTHON_MODULE(zoo) {
// An established convention for using boost.python.
using namespace boost::python;
def("hello", hello);
}
我运行下面的命令来编译。在
^{pr2}$
它被编译后给了我一个动物园。所以文件。当我试图导入并运行动物园。你好()在它工作的同一个文件夹中,但它没有在cpp\u examples文件夹之外导入sumith@rztl516-Lenovo-G575:~/cpp_examples$ python2
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zoo
>>> zoo.hello()
'hello, zoo'
>>> exit()
以下是cpp_examples文件夹之外的内容。在sumith@rztl516-Lenovo-G575:~$ python2
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zoo
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named zoo
>>>
为什么不导入该文件夹?。在编译时,我检查了python3,它根本没有编译,我在上面的命令中将-lpython2.7更改为-lpython3.4,并将-I/usr/include/python2.7更改为I/usr/include/python3.4,但在编译时它给了我错误/usr/bin/ld: cannot find -lpython3.4
如果我能得到这两个问题的答案,那将是一个很大的帮助。
谢谢您。在