Bug report #13686

[compile] qgis master fails with "error: ‘PyUnicode_AsUTF8’ was not declared in this scope"

Added by Donovan Cameron over 8 years ago. Updated about 8 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Build/Install
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:21717

Description

I'm getting an error during the build of QGIS master (r29362 fe6456f) for target qgispython in file "python/qgspythonutilsimpl.cpp"

This is on Linux 64-bit.

Scanning dependencies of target qgispython
[ 91%] Building CXX object src/python/CMakeFiles/qgispython.dir/qgispython.cpp.o
[ 91%] Building CXX object src/python/CMakeFiles/qgispython.dir/qgspythonutilsimpl.cpp.o
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp: In member function ‘QString QgsPythonUtilsImpl::getTraceback()’
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp:388:58: error: ‘PyUnicode_AsUTF8’ was not declared in this scope
result = QString::fromUtf8( PyUnicode_AsUTF8( obResult ) );
^
src/python/CMakeFiles/qgispython.dir/build.make:86: recipe for target 'src/python/CMakeFiles/qgispython.dir/qgspythonutilsimpl.cpp.o' failed
make[2]: *** [src/python/CMakeFiles/qgispython.dir/qgspythonutilsimpl.cpp.o] Error 1
CMakeFiles/Makefile2:3658: recipe for target 'src/python/CMakeFiles/qgispython.dir/all' failed
make[1]: *** [src/python/CMakeFiles/qgispython.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2


Related issues

Duplicated by QGIS Application - Bug report #13711: [compile] qgis master build fails at qgspythonutilsimpl.c... Closed 2015-10-29

Associated revisions

Revision a98fefd2
Added by Matthias Kuhn about 8 years ago

Merge pull request #2889 from m-kuhn/py3improvements

Simplify some python3 handling, refs #13686 (redmine)

History

#1 Updated by Johannes Kroeger over 8 years ago

Same problem here for weeks. There is some related discussion on http://lists.osgeo.org/pipermail/qgis-developer/2015-October/040063.html but it has not been fixed yet. :(

Archlinux, 64 bit.

#2 Updated by Donovan Cameron over 8 years ago

On Arch Linux, python version is currently at: python3 (3.5.1), python2 (2.7.11)

#3 Updated by Jürgen Fischer over 8 years ago

Donovan Cameron wrote:

On Arch Linux, python version is currently at: python3 (3.5.1), python2 (2.7.11)

And you're using 2.7.11?

#4 Updated by Donovan Cameron over 8 years ago

Yea, and these are some of the cmake options.

-DPYTHON_EXECUTABLE=/usr/bin/python2 \\
-DPYTHON_LIBRARY=/usr/lib/libpython2.7.so \\
-DPYTHON_INCLUDE_PATH=/usr/include/python2.7 \\
-DPYTHON_SITE_PACKAGES_DIR=/usr/lib/python2.7/site-packages \\

#5 Updated by Matthias Kuhn over 8 years ago

  • Status changed from Open to Feedback

Can you verify and update?

At the moment there should be no call to PyUnicode_AsUTF8 with python 2 (only PyUnicode_AsUTF8String)

#6 Updated by Donovan Cameron over 8 years ago

Hey Matthias,

Got an error from building qgis (2.13.0.r30691.45d5b1c) using make -j1 and ran a ccache -C before compiling.

Scanning dependencies of target qgispython
[ 91%] Building CXX object src/python/CMakeFiles/qgispython.dir/qgispython.cpp.o
[ 91%] Building CXX object src/python/CMakeFiles/qgispython.dir/qgspythonutilsimpl.cpp.o
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp: In member function ‘QString QgsPythonUtilsImpl::getTraceback()’:
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp:412:58: error: ‘PyUnicode_AsUTF8’ was not declared in this scope
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp: In member function ‘QString QgsPythonUtilsImpl::PyObjectToQString(PyObject*)’:
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp:524:55: error: ‘PyUnicode_AsUTF8’ was not declared in this scope
/tmp/makepkg/qgis-git/src/qgis/src/python/qgspythonutilsimpl.cpp:559:59: error: ‘PyUnicode_AsUTF8’ was not declared in this scope
src/python/CMakeFiles/qgispython.dir/build.make:86: recipe for target 'src/python/CMakeFiles/qgispython.dir/qgspythonutilsimpl.cpp.o' failed
make[2]: *** [src/python/CMakeFiles/qgispython.dir/qgspythonutilsimpl.cpp.o] Error 1
CMakeFiles/Makefile2:3658: recipe for target 'src/python/CMakeFiles/qgispython.dir/all' failed
make[1]: *** [src/python/CMakeFiles/qgispython.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Here's the output from the configure:

-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: /usr/lib/ccache/bin/cc
-- Check for working C compiler: /usr/lib/ccache/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/lib/ccache/bin/c++
-- Check for working CXX compiler: /usr/lib/ccache/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- QGIS version: 2.13.0 Master (21300)
-- Found GRASS 6: /opt/grass64 (6.4.6svn, off_t size = )
-- Found GRASS 7: /opt/grass (7.0.3svn, off_t size = )
-- Looking for openpty
-- Looking for openpty - not found
-- Looking for openpty
-- Looking for openpty - found
-- Found Proj: /usr/lib64/libproj.so
-- Found GEOS: /usr/lib/libgeos_c.so (3.5.0)
-- Found GDAL: /usr/lib/libgdal.so (2.0.1)
-- Found Expat: /lib64/libexpat.so
-- Found Spatialindex: /usr/lib64/libspatialindex.so
-- Found Qwt: /usr/lib64/libqwt.so (6.1.2)
-- Found Sqlite3: /usr/lib64/libsqlite3.so
-- Found PostgreSQL: /usr/lib/libpq.so
-- Found SpatiaLite: /usr/lib64/libspatialite.so
-- Looking for gaiaDropTable in /usr/lib64/libspatialite.so
-- Looking for gaiaDropTable in /usr/lib64/libspatialite.so - found
-- Looking for gaiaStatisticsInvalidate in /usr/lib64/libspatialite.so
-- Looking for gaiaStatisticsInvalidate in /usr/lib64/libspatialite.so - found
-- Looking for spatialite_init_ex in /usr/lib64/libspatialite.so
-- Looking for spatialite_init_ex in /usr/lib64/libspatialite.so - found
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /usr/bin/qmake-qt4 (found suitable version "4.8.7", minimum required is "4.8.0") 
-- Found Qt version: 4.8.7
-- Touch support disabled
-- Found QScintilla2: /usr/lib64/libqscintilla2.so (2.9)
-- Found QCA: /usr/lib64/libqca.so (2.1.1)
-- Found QCA OpenSSL plugin
-- Pedantic compiler settings enabled
-- Debug output enabled
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.11", minimum required is "2") 
-- Found PyQt4 version: 4.11.4
-- Found SIP version: 4.16.9
-- Found QScintilla2 PyQt module: 2.9
-- Found QwtPolar: /usr/lib64/libqwtpolar.so
-- Found GSL: -L/usr/lib -lgsl -lgslcblas -lm
-- Looking for updwtmpx
-- Looking for updwtmpx - found
-- Found FCGI: /usr/lib64/libfcgi.so
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/makepkg/qgis-git/src/qgis/build

#7 Updated by Doug Newgard over 8 years ago

I was able to build successfully on Arch. There was a breaking change to scripts/pyuic4-wrapper.sh (commit 7bab2e5036b5679f6dd3c6c7508c97fbde9d9006) that hardcodes a call to "python", but that was well after this report.

#8 Updated by Donovan Cameron over 8 years ago

I thought it might be a python hard coded issue. It's happened before =)

There is a Arch Linux system specific workaround here: https://wiki.archlinux.org/index.php/python#Dealing_with_version_problem_in_build_scripts which I haven't tested for this issue.

But I tried to modify/patch that file to hard code it with python2 instead of python, but got the same error. Do you think it's hard coded else where?

#9 Updated by Doug Newgard over 8 years ago

It could be, but as I said, it builds for me. I'm not using the PKGBUILD in the AUR, though; instead I adapted my release PKGBUILD. Give it a try instead. https://gist.github.com/Scimmia22/98a2ffcb4f3b405aa0d9

#10 Updated by Donovan Cameron about 8 years ago

Compiled fine now Doug, thanks.

I think you mentioned that QGIS finds python2 automagically before in the AUR, so as a note for this report, when these are included as cmake options, the build fails:

    -DPYTHON_EXECUTABLE=/usr/bin/python2 \\
    -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so \\
    -DPYTHON_INCLUDE_PATH=/usr/include/python2.7 \\
    -DPYTHON_SITE_PACKAGES_DIR=/usr/lib/python2.7/site-packages 

#11 Updated by Sandro Santilli about 8 years ago

Can this ticket be closed then or what's left to do exactly ?

#12 Updated by Donovan Cameron about 8 years ago

  • Status changed from Feedback to Closed

I think that it's when a user uses any of the PYTHON cmake options for a custom python (ex, python26, python27, python3) the build defaults to 'python' as the exec.
But in this case, when not building with those options it found the python2 exec and libs automatically.

So maybe when QGIS comes out with python3 support it's possible that this might cause a problem for some systems when they try to specify what version of python to build against, unless the plan is to drop python2 when the transition happens than this can be closed - which I did for now because building QGIS is working now.

Also available in: Atom PDF