matplotlib / basemap

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

ImportError: cannot import name 'dedent' from 'matplotlib.cbook' #494

Closed adibratul closed 4 years ago

adibratul commented 4 years ago

while installing basemap in ubuntu using following code

from mpl_toolkits.basemap import Basemap

got the following file missing.

`Traceback (most recent call last):

  File "<ipython-input-9-d9467465a3b6>", line 1, in <module>
    from mpl_toolkits.basemap import Basemap

  File "/home/adib/.local/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py", line 50, in <module>
    from .proj import Proj

  File "/home/adib/.local/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/adib/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/__init__.py)`
WeatherGod commented 4 years ago

Whatever version of basemap you installed is not compatible with that version of matplotlib. Use the most recent tarball from github.

Also, Basemap is no longer supported! The End of Life has been announced years ago. Stop using basemap, use Cartopy instead!

On Sat, Jul 18, 2020 at 12:57 PM adibratul notifications@github.com wrote:

while installing basemap in ubuntu using following code

from mpl_toolkits.basemap import Basemap

got the following file missing.

`Traceback (most recent call last):

File "", line 1, in from mpl_toolkits.basemap import Basemap

File "/home/adib/.local/lib/python3.7/site-packages/mpl_toolkits/basemap/init.py", line 50, in from .proj import Proj

File "/home/adib/.local/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/adib/anaconda3/lib/python3.7/site-packages/matplotlib/cbook/init.py)`

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

adibratul commented 4 years ago

yes working with cartopy instead of basemap /. Thanks

EJFielding commented 4 years ago

@WeatherGod The present version of proj.py here on GitHub still has the import of dedent in line 6:

from matplotlib.cbook import dedent
ReimarBauer commented 4 years ago

this should become replaced by

from inspect import cleandoc as dedent

SanjaySNegi commented 3 years ago

I solved this problem by downgrading matplotlib version to 3.2. Follow the site link:--- https://stackoverflow.com/questions/63839163/maplotlib-and-basemap-cannot-import-name-dedent

WeatherGod commented 3 years ago

I just noticed that the basemap version is v1.3.0 from the main conda channel. There is no such release: https://github.com/matplotlib/basemap/tags. It would seem that conda accidentally built a package using an older version of the code (because this bug has been fixed for a while now). The correct solution would be to install basemap version 1.2.2 from conda-forge and allow matplotlib to be upgraded to whichever version you'd like.

Also, please move to cartopy!

On Wed, Nov 10, 2021 at 6:48 AM sanjay @.***> wrote:

I solved this problem downgrading matplotlib version to 3.2. Follow the site link:---

https://stackoverflow.com/questions/63839163/maplotlib-and-basemap-cannot-import-name-dedent

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/494#issuecomment-965054686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACHF6CUL5NFJGBA2TKDCC3ULJLXTANCNFSM4PAD5M6Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.