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

installation fails on ubuntu 21.04 with Python 3.9.5 #518

Closed
thdb-theo opened this issue Jun 24, 2021 · 6 comments
Closed

installation fails on ubuntu 21.04 with Python 3.9.5 #518

thdb-theo opened this issue Jun 24, 2021 · 6 comments

Comments

@thdb-theo
Copy link

I have succesfully install geos, but running sudo python3 setup.py install fails with the following error:

checking for GEOS lib in /root ....
checking for GEOS lib in /root/local ....
checking for GEOS lib in /usr ....
GEOS lib (version 3.9.0) found in /usr
running install
running bdist_egg
running egg_info
running build_src
build_src
building extension "_geoslib" sources
build_src: building npy-pkg config files
creating basemap.egg-info
writing basemap.egg-info/PKG-INFO
writing dependency_links to basemap.egg-info/dependency_links.txt
writing namespace_packages to basemap.egg-info/namespace_packages.txt
writing requirements to basemap.egg-info/requires.txt
writing top-level names to basemap.egg-info/top_level.txt
writing manifest file 'basemap.egg-info/SOURCES.txt'
reading manifest file 'basemap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'basemap.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/mpl_toolkits
creating build/lib.linux-x86_64-3.9/mpl_toolkits/basemap

.
.
.
.

A bunch of compiler notes and warnings. Then the error:

      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~~^
src/_geoslib.c: In function ‘__Pyx_modinit_type_init_code’:
src/_geoslib.c:5678:36: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
 5678 |   __pyx_type_8_geoslib_BaseGeometry.tp_print = 0;
      |                                    ^
src/_geoslib.c:5686:31: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
 5686 |   __pyx_type_8_geoslib_Polygon.tp_print = 0;
      |                               ^
src/_geoslib.c:5694:34: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
 5694 |   __pyx_type_8_geoslib_LineString.tp_print = 0;
      |                                  ^
src/_geoslib.c:5702:29: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
 5702 |   __pyx_type_8_geoslib_Point.tp_print = 0;
      |                             ^

error: Command "x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-1n6GrT/python3.9-3.9.5=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-1n6GrT/python3.9-3.9.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include -I/usr/local/lib/python3.9/dist-packages/numpy/core/include -I/usr/local/lib/python3.9/dist-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/usr/include/python3.9 -c src/_geoslib.c -o build/temp.linux-x86_64-3.9/src/_geoslib.o -MMD -MF build/temp.linux-x86_64-3.9/src/_geoslib.o.d -msse -msse2 -msse3" failed with exit status 1

########### EXT COMPILER OPTIMIZATION ###########
Platform      : 
  Architecture: x64
  Compiler    : gcc

CPU baseline  : 
  Requested   : 'min'
  Enabled     : SSE SSE2 SSE3
  Flags       : -msse -msse2 -msse3
  Extra checks: none

CPU dispatch  : 
  Requested   : 'max -xop -fma4'
  Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
  Generated   : none
CCompilerOpt._cache_write[796] : write cache to path -> /home/theodor/Downloads/basemap/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_ext.py

Installing using pip results in the same error.

@molinav
Copy link
Member

molinav commented Jun 24, 2021

It seems that tp_print was removed in CPython 3.9 (see https://bugs.python.org/issue39361), so this error is probably occurring in the conversion of _geoslib.pyx to _geoslib.c.

Are you using the _geoslib.c file from the repo? It might work if you remove the C file to force the generation of this file again by Cython. This _geoslib.c file in the repo is probably super-old and ideally it should be deleted and add Cython as build dependency.

@thdb-theo
Copy link
Author

thdb-theo commented Jun 24, 2021

Thanks, that made me able to install, but led to another (possibly related) issue. When importing Basemap i get this error:

>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/theodor/.local/lib/python3.9/site-packages/basemap-1.2.2+dev-py3.9-linux-x86_64.egg/mpl_toolkits/basemap/__init__.py", line 53, in <module>
    import _geoslib
ImportError: libgeos-3.9.1.so: cannot open shared object file: No such file or directory
>>> 

I have libgeos-dev 3.9.0-1installed

@molinav
Copy link
Member

molinav commented Jun 24, 2021

That looks strange to me, in the original message the output says:

GEOS lib (version 3.9.0) found in /usr

so I would expect basemap to request libgeos-3.9.0.so, which is available in Ubuntu 21.04 under /usr/lib/x86_64-linux-gnu/libgeos-3.9.0.so when you install libgeos-3.9.0 (this package gets installed automatically with libgeos-dev). Do you have several GEOS versions installed?

@thdb-theo
Copy link
Author

Thank for your help! I fixed it by removing 3.9.1 and installing 3.9.0.

@GeoFelpave
Copy link

GeoFelpave commented Jul 24, 2021

Just to add here. The following worked for me without having to altered the version of Python.

sudo apt -y install libgeos-dev
pip3 install git+https://github.com/matplotlib/basemap/

@molinav
Copy link
Member

molinav commented Dec 5, 2021

@thdb-theo @GeoFelpave I just uploaded preliminary wheel binaries of the future basemap version 1.3.0 (with bundled libgeos_c). In case you are still interested you can try out with (for Python 2.7 and 3.5 to 3.9):

python -m pip install "basemap-data == 1.3.0b1" "basemap == 1.3.0b1"

@molinav molinav closed this as completed Dec 5, 2021
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