How to import the string library in Cython?

Hello!

There is a pyx file

cdef extern from "Person.h" namespace "person":
 cdef cppclass CppPerson:
 CppPerson() except +
 CppPerson(string name, int age) except +


cdef class Person:
 cdef CppPerson *cpp_person

 def __cinit__(self):
 self.cpp_person = new CppPerson()
 if self.cpp_person == NULL:
 raise MemoryError('Not enough memory.')

 def __dealloc__(self):
 del self.cpp_person


4 line I need to use the string data type
How do I add it?
How to do the import?

Yet that's the error
C:\PyScripterProjects\Расширения for Python3 with C++\person2 are>py setup.py build_ex
t --inplace
Compiling person_module.pyx because it changed.
[1/1] Cythonizing person_module.pyx
C:\Python37\lib\site-packages\Cython\Compiler\Main.py:367: FutureWarning: Cython
 directive 'language_level' not set, using 2 for now (Py2). This will change in
a later release! File: C:\PyScripterProjects\Расширения for Python3 with C++\Perso
n2\person_module.pyx
 tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "Person.h" namespace "person":
 cdef cppclass CppPerson:
 CppPerson() except +
 CppPerson(string name, int age) except +
^
------------------------------------------------------------

person_module.pyx:4:18: 'string' is not a type identifier
Traceback (most recent call last):
 File "setup.py", line 8, in <module>
 language="c++", # generate and compile C++
code
 File "C:\Python37\lib\site-packages\Cython\Build\Dependencies.py", line 1097,
in cythonize
cythonize_one(*args)
 File "C:\Python37\lib\site-packages\Cython\Build\Dependencies.py", line 1220,
in cythonize_one
 raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: person_module.pyx

C:\PyScripterProjects\Расширения for Python3 with C++\person2 are>
April 3rd 20 at 17:22
0 answer

Find more questions by tags Python