问题
I've just built Boost Python on Windows 10 with an Anaconda version of Python 3.5 (64 bit). I used these instructions modified to my suit my installation and have successfully built the testCode.cpp using Visual Studio 2015:
#include <boost/python.hpp>
using namespace boost::python;
int main()
{
try {
Py_Initialize();
object main_module((
handle<>(borrowed(PyImport_AddModule("__main__")))));
object main_namespace = main_module.attr("__dict__");
handle<> ignored(( PyRun_String( "print (\"Hello, World\")",
Py_file_input,
main_namespace.ptr(),
main_namespace.ptr() ) ));
} catch( error_already_set ) {
PyErr_Print();
}
}
However when I run the application I get these errors:
C:\Users\Stephen\Source\Repos\TestPythonEmbedding\x64\Release>TestPythonEmbedding
Failed to import the site module
Traceback (most recent call last):
File "C:\Users\Stephen\Anaconda3\Lib\site.py", line 73, in <module>
import os
File "C:\Users\Stephen\Anaconda3\Lib\os.py", line 652, in <module>
from _collections_abc import MutableMapping
File "C:\Users\Stephen\Anaconda3\Lib\_collections_abc.py", line 64
async def _ag(): yield
^
SyntaxError: 'yield' inside async function
Does anyone know what's wrong here and how to fix it?
Thanks
来源:https://stackoverflow.com/questions/48552092/boost-python-embedding-error