matplotlib / basemap

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

basemap cannot be imported with matplotlib-3.3.0 #495

Closed joernu76 closed 4 years ago

joernu76 commented 4 years ago

To replicate, install fresh packages in conda

conda create -n basemap-test -c conda-forge basemap matplotlib

all packages:

 (e) basemap-test  ~  conda list                                     
# packages in environment at /home/icg173/anaconda3/envs/basemap-test:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                      1_llvm    conda-forge
basemap                   1.2.1            py37hd1be537_2    conda-forge
blas                      2.17                   openblas    conda-forge
ca-certificates           2020.6.20            hecda079_0    conda-forge
certifi                   2020.6.20        py37hc8dfbb8_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
dbus                      1.13.6               he372182_0    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
fontconfig                2.13.1            h86ecdb6_1001    conda-forge
freetype                  2.10.2               he06d7ca_0    conda-forge
geos                      3.8.0                he1b5a44_1    conda-forge
gettext                   0.19.8.1          hc5be6a0_1002    conda-forge
glib                      2.65.0               h6f030ca_0    conda-forge
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
icu                       64.2                 he1b5a44_1    conda-forge
intel-openmp              2019.4                      243  
jpeg                      9d                   h516909a_0    conda-forge
kiwisolver                1.2.0            py37h99015e2_0    conda-forge
lcms2                     2.11                 hbd6801e_0    conda-forge
ld_impl_linux-64          2.34                 hc38a660_9    conda-forge
libblas                   3.8.0               17_openblas    conda-forge
libcblas                  3.8.0               17_openblas    conda-forge
libclang                  9.0.1           default_hde54327_0    conda-forge
libedit                   3.1.20191231         h46ee950_1    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 9.3.0               h24d8f2e_13    conda-forge
libgfortran-ng            7.5.0               hdf63c60_13    conda-forge
libiconv                  1.15              h516909a_1006    conda-forge
liblapack                 3.8.0               17_openblas    conda-forge
liblapacke                3.8.0               17_openblas    conda-forge
libllvm9                  9.0.1                he513fc3_1    conda-forge
libopenblas               0.3.10          pthreads_hb3c22a3_4    conda-forge
libpng                    1.6.37               hed695b0_1    conda-forge
libstdcxx-ng              9.3.0               hdf63c60_13    conda-forge
libtiff                   4.1.0                hc7e4089_6    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libwebp-base              1.1.0                h516909a_3    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxkbcommon              0.10.0               he1b5a44_0    conda-forge
libxml2                   2.9.10               hee79883_0    conda-forge
llvm-openmp               10.0.1               hc9558a2_0    conda-forge
lz4-c                     1.9.2                he1b5a44_1    conda-forge
matplotlib                3.3.0                         1    conda-forge
matplotlib-base           3.3.0            py37hd478181_1    conda-forge
mkl                       2019.5                      281    conda-forge
mkl-service               2.3.0            py37h516909a_0    conda-forge
mkl_fft                   1.1.0            py37hc1659b7_1    conda-forge
mkl_random                1.1.0            py37hb3f55d8_0    conda-forge
ncurses                   6.2                  he1b5a44_1    conda-forge
nspr                      4.27                 he1b5a44_0    conda-forge
nss                       3.47                 he751ad9_0    conda-forge
numpy                     1.19.1           py37h8960a57_0    conda-forge
numpy-base                1.18.5           py37h2f8d375_0  
olefile                   0.46                       py_0    conda-forge
openssl                   1.1.1g               h516909a_1    conda-forge
pcre                      8.44                 he1b5a44_0    conda-forge
pillow                    7.2.0            py37h718be6c_1    conda-forge
pip                       20.2                       py_0    conda-forge
proj4                     5.2.0             he1b5a44_1006    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyproj                    1.9.6           py37h516909a_1002    conda-forge
pyqt                      5.12.3           py37h8685d9f_3    conda-forge
pyqt5-sip                 4.19.18                  pypi_0    pypi
pyqtchart                 5.12                     pypi_0    pypi
pyqtwebengine             5.12.1                   pypi_0    pypi
pyshp                     2.1.0                      py_0    conda-forge
python                    3.7.8           h6f2ec95_1_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.7                     1_cp37m    conda-forge
qt                        5.12.5               hd8c4c69_1    conda-forge
readline                  8.0                  he28a2e2_2    conda-forge
setuptools                49.2.1           py37hc8dfbb8_0    conda-forge
sip                       4.19.23          py37h3340039_0    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.32.3               hcee41ef_1    conda-forge
tk                        8.6.10               hed695b0_0    conda-forge
tornado                   6.0.4            py37h8f50634_1    conda-forge
wheel                     0.34.2                     py_1    conda-forge
xorg-libxau               1.0.9                h14c3975_0    conda-forge
xorg-libxdmcp             1.1.3                h516909a_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h516909a_1006    conda-forge
zstd                      1.4.5                h6597ccf_2    conda-forge

to cause the error:

 (e) basemap-test  ~  python
Python 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpl_toolkits.basemap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/icg173/anaconda3/envs/basemap-test/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py", line 50, in <module>
    from .proj import Proj
  File "/home/icg173/anaconda3/envs/basemap-test/lib/python3.7/site-packages/mpl_toolkits/basemap/proj.py", line 6, in <module>
    from matplotlib.cbook import dedent
ImportError: cannot import name 'dedent' from 'matplotlib.cbook' (/home/icg173/anaconda3/envs/basemap-test/lib/python3.7/site-packages/matplotlib/cbook/__init__.py)

A simple fix would be to replace line 6 in basemap/proj.py

from matplotlib.cbook import dedent                                                                                                                                                           

with

try:
    from inspect import cleandoc as dedent                                                                                                                                                     
except ImportError:
    # Deprecated as of version 3.1. Not quite the same
    # as textwrap.dedent.
    from matplotlib.cbook import dedent

as already implemented in basemap/init.py

I can probably prepare a merge request. Would this be useful for such a simple change?

WeatherGod commented 4 years ago

Sure, feel free to do so, and I'll merge it. Do keep in mind that this package isn't really maintained anymore. Please try Cartopy instead.

On Sun, Aug 2, 2020 at 2:57 PM joernu76 notifications@github.com wrote:

To replicate, install fresh packages in conda

conda create -n basemap-test -c conda-forge basemap matplotlib

all packages:

(e) basemap-test  ~  conda list

packages in environment at /home/icg173/anaconda3/envs/basemap-test:

#

Name Version Build Channel

_libgcc_mutex 0.1 conda_forge conda-forge

_openmp_mutex 4.5 1_llvm conda-forge

basemap 1.2.1 py37hd1be537_2 conda-forge

blas 2.17 openblas conda-forge

ca-certificates 2020.6.20 hecda079_0 conda-forge

certifi 2020.6.20 py37hc8dfbb8_0 conda-forge

cycler 0.10.0 py_2 conda-forge

dbus 1.13.6 he372182_0 conda-forge

expat 2.2.9 he1b5a44_2 conda-forge

fontconfig 2.13.1 h86ecdb6_1001 conda-forge

freetype 2.10.2 he06d7ca_0 conda-forge

geos 3.8.0 he1b5a44_1 conda-forge

gettext 0.19.8.1 hc5be6a0_1002 conda-forge

glib 2.65.0 h6f030ca_0 conda-forge

gst-plugins-base 1.14.5 h0935bb2_2 conda-forge

gstreamer 1.14.5 h36ae1b5_2 conda-forge

icu 64.2 he1b5a44_1 conda-forge

intel-openmp 2019.4 243

jpeg 9d h516909a_0 conda-forge

kiwisolver 1.2.0 py37h99015e2_0 conda-forge

lcms2 2.11 hbd6801e_0 conda-forge

ld_impl_linux-64 2.34 hc38a660_9 conda-forge

libblas 3.8.0 17_openblas conda-forge

libcblas 3.8.0 17_openblas conda-forge

libclang 9.0.1 default_hde54327_0 conda-forge

libedit 3.1.20191231 h46ee950_1 conda-forge

libffi 3.2.1 he1b5a44_1007 conda-forge

libgcc-ng 9.3.0 h24d8f2e_13 conda-forge

libgfortran-ng 7.5.0 hdf63c60_13 conda-forge

libiconv 1.15 h516909a_1006 conda-forge

liblapack 3.8.0 17_openblas conda-forge

liblapacke 3.8.0 17_openblas conda-forge

libllvm9 9.0.1 he513fc3_1 conda-forge

libopenblas 0.3.10 pthreads_hb3c22a3_4 conda-forge

libpng 1.6.37 hed695b0_1 conda-forge

libstdcxx-ng 9.3.0 hdf63c60_13 conda-forge

libtiff 4.1.0 hc7e4089_6 conda-forge

libuuid 2.32.1 h14c3975_1000 conda-forge

libwebp-base 1.1.0 h516909a_3 conda-forge

libxcb 1.13 h14c3975_1002 conda-forge

libxkbcommon 0.10.0 he1b5a44_0 conda-forge

libxml2 2.9.10 hee79883_0 conda-forge

llvm-openmp 10.0.1 hc9558a2_0 conda-forge

lz4-c 1.9.2 he1b5a44_1 conda-forge

matplotlib 3.3.0 1 conda-forge

matplotlib-base 3.3.0 py37hd478181_1 conda-forge

mkl 2019.5 281 conda-forge

mkl-service 2.3.0 py37h516909a_0 conda-forge

mkl_fft 1.1.0 py37hc1659b7_1 conda-forge

mkl_random 1.1.0 py37hb3f55d8_0 conda-forge

ncurses 6.2 he1b5a44_1 conda-forge

nspr 4.27 he1b5a44_0 conda-forge

nss 3.47 he751ad9_0 conda-forge

numpy 1.19.1 py37h8960a57_0 conda-forge

numpy-base 1.18.5 py37h2f8d375_0

olefile 0.46 py_0 conda-forge

openssl 1.1.1g h516909a_1 conda-forge

pcre 8.44 he1b5a44_0 conda-forge

pillow 7.2.0 py37h718be6c_1 conda-forge

pip 20.2 py_0 conda-forge

proj4 5.2.0 he1b5a44_1006 conda-forge

pthread-stubs 0.4 h14c3975_1001 conda-forge

pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge

pyproj 1.9.6 py37h516909a_1002 conda-forge

pyqt 5.12.3 py37h8685d9f_3 conda-forge

pyqt5-sip 4.19.18 pypi_0 pypi

pyqtchart 5.12 pypi_0 pypi

pyqtwebengine 5.12.1 pypi_0 pypi

pyshp 2.1.0 py_0 conda-forge

python 3.7.8 h6f2ec95_1_cpython conda-forge

python-dateutil 2.8.1 py_0 conda-forge

python_abi 3.7 1_cp37m conda-forge

qt 5.12.5 hd8c4c69_1 conda-forge

readline 8.0 he28a2e2_2 conda-forge

setuptools 49.2.1 py37hc8dfbb8_0 conda-forge

sip 4.19.23 py37h3340039_0 conda-forge

six 1.15.0 pyh9f0ad1d_0 conda-forge

sqlite 3.32.3 hcee41ef_1 conda-forge

tk 8.6.10 hed695b0_0 conda-forge

tornado 6.0.4 py37h8f50634_1 conda-forge

wheel 0.34.2 py_1 conda-forge

xorg-libxau 1.0.9 h14c3975_0 conda-forge

xorg-libxdmcp 1.1.3 h516909a_0 conda-forge

xz 5.2.5 h516909a_1 conda-forge

zlib 1.2.11 h516909a_1006 conda-forge

zstd 1.4.5 h6597ccf_2 conda-forge

to cause the error:

(e) basemap-test  ~  python

Python 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08)

[GCC 7.5.0] on linux

Type "help", "copyright", "credits" or "license" for more information.

import mpl_toolkits.basemap

Traceback (most recent call last):

File "", line 1, in

File "/home/icg173/anaconda3/envs/basemap-test/lib/python3.7/site-packages/mpl_toolkits/basemap/init.py", line 50, in

from .proj import Proj

File "/home/icg173/anaconda3/envs/basemap-test/lib/python3.7/site-packages/mpl_toolkits/basemap/proj.py", line 6, in

from matplotlib.cbook import dedent

ImportError: cannot import name 'dedent' from 'matplotlib.cbook' (/home/icg173/anaconda3/envs/basemap-test/lib/python3.7/site-packages/matplotlib/cbook/init.py)

A simple fix would be to replace line 6 in basemap/proj.py

from matplotlib.cbook import dedent

with

try:

from inspect import cleandoc as dedent

except ImportError:

# Deprecated as of version 3.1. Not quite the same

# as textwrap.dedent.

from matplotlib.cbook import dedent

as already implemented in basemap/init.py

I can probably prepare a merge request. Would this be useful for such a simple change?

— 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/495, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACHF6BYM7BGWV3MQ4QOLR3R6WZJRANCNFSM4PSVZVCA .

joernu76 commented 4 years ago

We also try to work with cartopy, but cartopy still has a lot of serious issues, which are not as easily addressed as this for our usecase (e.g. with stereographic projections).

joernu76 commented 4 years ago

The tests seem to fail due to failure to install libgeos with the desired version, not related with my changes IMO.

OK, the travis stuff is quite outdated. I try to fix it separately, but with the current state of matplotlib, it will be likely impossible to get it to pass without accepting both changes.

joernu76 commented 4 years ago

See also issue in MSS https://bitbucket.org/wxmetvis/mss/issues/574/matplotlib-cannot-be-upgraded-due-to-error

WeatherGod commented 4 years ago

Closed by #496

joernu76 commented 4 years ago

I need the working basemap in anaconda. Could you do a new release, please? 1.2.2rel? Update: Okay, I see that basemap is already decoupled from releases here. Forget about my request. Thanks, again!

ghost commented 4 years ago

@joernu76 : how did you get the fix in anaconda?
I conda-installed the latest basemap=1.3 but the fix is not implemented.

Personally, I downgraded matplotlib to 2.2.4 to get it working.

joernu76 commented 4 years ago

@Kerybas The fix is not implemented in anaconda, yet. There are some problems with respect to release numbers due to the deprecation of basemap. Downloading and manually installing basemap from here might help, currently, or to manually patch your anaconda-basemap with the latest diff (what I did until the patch goes into anaconda; I hope this will happen within the next few weeks...).

vic1309 commented 4 years ago

@joernu76 @Kerybas

I'm facing the same problem here. Any luck so far?

joernu76 commented 4 years ago

The bug was fixed in this repository and it has also been fixed since 19th Aug in the anaconda distribution. See here https://github.com/conda-forge/basemap-feedstock/issues/64 So either using a fresh anaconda installation or a clone of this repository should work unless you discovered a new bug.