Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

‘PyUnicode_AsUTF8’ was not declared in this scope when building #778

Open
TCopcutt opened this issue Jul 4, 2022 · 3 comments
Open

Comments

@TCopcutt
Copy link

TCopcutt commented Jul 4, 2022

Trying to install Pangolin using Build instructions provided and get this error. Making a modification to the pyinterpreter.cpp as suggested gives me other errors. Cmake version 3.23.2 and Ubuntu 18.04. Tried instructions here which did not work either.

[ 54%] Building CXX object CMakeFiles/pango_python.dir/components/pango_python/src/pyinterpreter.cpp.o
In file included from /home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp:27:0:
/home/user/Pangolin/components/pango_python/include/pangolin/python/pyinterpreter.h:40:7: warning: ‘pangolin::PyInterpreter’ declared with greater visibility than the type of its field ‘pangolin::PyInterpreter::guard’ [-Wattributes]
 class PyInterpreter : public InterpreterInterface
       ^~~~~~~~~~~~~
/home/user/Pangolin/components/pango_python/include/pangolin/python/pyinterpreter.h:40:7: warning: ‘pangolin::PyInterpreter’ declared with greater visibility than the type of its field ‘pangolin::PyInterpreter::pycompleter’ [-Wattributes]
/home/user/Pangolin/components/pango_python/include/pangolin/python/pyinterpreter.h:40:7: warning: ‘pangolin::PyInterpreter’ declared with greater visibility than the type of its field ‘pangolin::PyInterpreter::pycomplete’ [-Wattributes]
/home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp: In member function ‘std::__cxx11::string pangolin::PyInterpreter::ToString(const pybind11::object&)’:
/home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp:113:24: error: ‘PyUnicode_AsUTF8’ was not declared in this scope
     return std::string(PyUnicode_AsUTF8(pystr.ptr()));
                        ^~~~~~~~~~~~~~~~
/home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp:113:24: note: suggested alternative: ‘PyUnicode_Type’
     return std::string(PyUnicode_AsUTF8(pystr.ptr()));
                        ^~~~~~~~~~~~~~~~
                        PyUnicode_Type
/home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp: In member function ‘virtual std::vector<std::__cxx11::basic_string<char> > pangolin::PyInterpreter::Complete(const string&, int)’:
/home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp:156:37: error: ‘PyUnicode_AsUTF8’ was not declared in this scope
                 std::string res_str(PyUnicode_AsUTF8(result));
                                     ^~~~~~~~~~~~~~~~
/home/user/Pangolin/components/pango_python/src/pyinterpreter.cpp:156:37: note: suggested alternative: ‘PyUnicode_Type’
                 std::string res_str(PyUnicode_AsUTF8(result));
                                     ^~~~~~~~~~~~~~~~
                                     PyUnicode_Type
CMakeFiles/pango_python.dir/build.make:75: recipe for target 'CMakeFiles/pango_python.dir/components/pango_python/src/pyinterpreter.cpp.o' failed
make[2]: *** [CMakeFiles/pango_python.dir/components/pango_python/src/pyinterpreter.cpp.o] Error 1
CMakeFiles/Makefile2:701: recipe for target 'CMakeFiles/pango_python.dir/all' failed
make[1]: *** [CMakeFiles/pango_python.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

@jih189
Copy link

jih189 commented Sep 30, 2022

I met the same problem.

@jih189
Copy link

jih189 commented Sep 30, 2022

Well. If you do not use python with it, the solution I have here is that comment out the ${CMAKE_CURRENT_LIST_DIR}/src/pyinterpreter.cpp in Pangolin/components/pango_python/CMakeLists.txt.
It should be fine.

@stevenlovegrove
Copy link
Owner

It looks like PyUnicode_AsUTF8
is only available with python 3.X and I guess you're using 2.X. You could switch to python3 or you could introduce a guard here https://github.com/stevenlovegrove/Pangolin/blob/master/components/pango_python/src/pyinterpreter.cpp#L113 and https://github.com/stevenlovegrove/Pangolin/blob/master/components/pango_python/src/pyinterpreter.cpp#L155 based on version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants