matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
779 stars 392 forks source link

No module named '_geoslib' #421

Closed StSav012 closed 6 years ago

StSav012 commented 6 years ago

Hi! When trying to from mpl_toolkits.basemap import Basemap, Python 3.7.0 enters "/usr/lib/python3/dist-packages/mpl_toolkits/basemap/__init__.py", finds line 39: import _geoslib and raises an error: ModuleNotFoundError: No module named '_geoslib'. I have no idea, why it's only me who suffers it. I checked matplotlib both 2.2.3 and 3.0.0rc2, basemap is 1.0.0. Strangely, though, Python 3.6.6 finds everything and works well.

Unlike some people here, I can't compile basemap from sources:

  building '_geoslib' extension
  compiling C sources
  C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

  creating build/temp.linux-x86_64-3.7/src
  compile options: '-I/usr/include -I['/usr/local/lib/python3.7/dist-packages/numpy/core/include'] -I/usr/local/lib/python3.7/dist-packages/numpy/core/include -I/usr/include/python3.7m -c'
  x86_64-linux-gnu-gcc: src/_geoslib.c
  In file included from /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1821,
                   from /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                   from /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from src/_geoslib.c:247:
  /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   #warning "Using deprecated NumPy API, disable it by " \
    ^~~~~~~
  src/_geoslib.c: In function ‘__pyx_pf_8_geoslib_12BaseGeometry_is_valid’:
  src/_geoslib.c:1139:43: warning: passing argument 1 of ‘GEOSisValid’ from incompatible pointer type [-Wincompatible-pointer-types]
     __pyx_v_valid = GEOSisValid(__pyx_v_self->_geom);
                                 ~~~~~~~~~~~~^~~~~~~

etc. It's the matter of another question. Now, where would I get that _geoslib for Python 3.7.0 to import?

WeatherGod commented 6 years ago

The recommended method of installing basemap now is through the conda-forge channel. The _geolib.so should have come from compiling the cythonized _geo.pyx, so something is wonky there.

On Sun, Sep 9, 2018 at 3:55 PM Anton Yablokov notifications@github.com wrote:

Hi! When trying to from mpl_toolkits.basemap import Basemap, Python 3.7.0 enters "/usr/lib/python3/dist-packages/mpl_toolkits/basemap/init.py", finds line 39: import _geoslib and raises an error: ModuleNotFoundError: No module named '_geoslib'. I have no idea, why it's only me who suffers it. I checked matplotlib both 2.2.3 and 3.0.0rc2, basemap is 1.0.0. Strangely, though, Python 3.6.6 finds everything and works well.

Unlike some people here, I can't compile basemap from sources:

building '_geoslib' extension compiling C sources C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

creating build/temp.linux-x86_64-3.7/src compile options: '-I/usr/include -I['/usr/local/lib/python3.7/dist-packages/numpy/core/include'] -I/usr/local/lib/python3.7/dist-packages/numpy/core/include -I/usr/include/python3.7m -c' x86_64-linux-gnu-gcc: src/_geoslib.c In file included from /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1821, from /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4, from src/_geoslib.c:247: /usr/local/lib/python3.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by " \

^~~~~~~

src/_geoslib.c: In function ‘__pyx_pf_8_geoslib_12BaseGeometry_is_valid’: src/_geoslib.c:1139:43: warning: passing argument 1 of ‘GEOSisValid’ from incompatible pointer type [-Wincompatible-pointer-types] pyx_v_valid = GEOSisValid(pyx_v_self->_geom);



etc.
It's the matter of another question. Now, where would I get that _geoslib
for Python 3.7.0 to import?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/matplotlib/basemap/issues/421>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-G8xl4D5xeMi50KwuqYvEcL0RSS8ks5uZXJIgaJpZM4WgbPu>
.
StSav012 commented 6 years ago

Very well. However, Python 3.6.6 finds the module. As a hotfix, the command ln -s /usr/lib/python3/dist-packages/_geoslib.cpython-3{6,7}m-x86_64-linux-gnu.so helped except for a RuntimeWarning about the versions mismatch. Apparently, I've got _geoslib.cpython-36m-x86_64-linux-gnu.so from python3-mpltoolkits.basemap package. But in the first place, why isn't the _geoslib supplied for Python 3.7.0 via pip? Neither is basemap itself.

I see your point about conda-forge. Nonetheless, I believe, installing Anaconda (622 MB) just for one module is an overkill. Finally, it's not for Python 3.7 yet either.

efiring commented 6 years ago

@StSav012 In your first comment you showed only the first part of the output from your attempt to build _geoslib, so there was no clue as to why it failed in the end. (The warnings were probably irrelevant.) That failure would seem to be the root of your problem, so it might be worth looking at it. As far as other people having problems or not: I doubt many people are building basemap and _geoslib for py 3.7 yet. A general point: basemap is in minimal maintenance mode unless and until someone volunteers to put more time into it. Alternatively, depending on what you are doing, you may be able to use cartopy instead. Although it is the designated replacement for basemap, unfortunately, it does not yet have all of basemap's capabilities.

StSav012 commented 6 years ago

Finally, as libgeos-3.7.0 has been released, I'm able to run

 pip3 install https://github.com/matplotlib/basemap/archive/master.zip

without errors. After that, basemap works fine again.

The code for libgeos-3.7.0 became available the day I reported the issue (a coincidence?) but only recently I've got the binary.