Skip to content

Issue importing proplot #454

Open
Open

Description

@chfite

I have received the following error when trying to import proplot. I have tried switching to prior versions of the "packaging" module (with no luck) since it seems to have an issue with that in cartopy when proplot is imported. Is this a proplot issue, cartopy issue, or some other issue? Any advice on how to fix it?

proplot version is 0.9.7
cartopy version is 0.22.0
packing versions 21.3 up to 24.0 have been tested
matplotlib version 3.4.3
python version is 3.9

In [1]: import proplot
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 import proplot

File ~/anaconda3/envs/cf3/lib/python3.9/site-packages/proplot/__init__.py:38
     36     from .colors import *  # noqa: F401 F403
     37 with _benchmark('ticker'):
---> 38     from .ticker import *  # noqa: F401 F403
     39 with _benchmark('scale'):
     40     from .scale import *  # noqa: F401 F403

File ~/anaconda3/envs/cf3/lib/python3.9/site-packages/proplot/ticker.py:18
     16 try:
     17     import cartopy.crs as ccrs
---> 18     from cartopy.mpl.ticker import (
     19         _PlateCarreeFormatter, LatitudeFormatter, LongitudeFormatter
     20     )
     21 except ModuleNotFoundError:
     22     ccrs = None

File ~/anaconda3/envs/cf3/lib/python3.9/site-packages/cartopy/mpl/ticker.py:13
     10 import numpy as np
     12 import cartopy.crs as ccrs
---> 13 from cartopy.mpl.geoaxes import GeoAxes
     16 class _PlateCarreeFormatter(Formatter):
     17     """
     18     Base class for formatting ticks on geographical axes using a
     19     rectangular projection (e.g. Plate Carree, Mercator).
     20 
     21     """

File ~/anaconda3/envs/cf3/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:43
     41 import cartopy.mpl.contour
     42 import cartopy.mpl.feature_artist as feature_artist
---> 43 import cartopy.mpl.geocollection
     44 import cartopy.mpl.patch as cpatch
     45 from cartopy.mpl.slippy_image_artist import SlippyImageArtist

File ~/anaconda3/envs/cf3/lib/python3.9/site-packages/cartopy/mpl/geocollection.py:13
      9 import numpy.ma as ma
     10 import packaging
---> 13 _MPL_VERSION = packaging.version.parse(mpl.__version__)
     16 def _split_wrapped_mesh_data(C, mask):
     17     """
     18     Helper function for splitting GeoQuadMesh array values between the
     19     pcolormesh and pcolor objects when wrapping.  Apply a mask to the grid
     20     cells that should not be plotted with each method.
     21 
     22     """

AttributeError: module 'packaging' has no attribute 'version'

Activity

  1. julian-belina commented on Apr 20, 2024

    @julian-belina

    Have you tried downgrading cartopy? The error seems to be in this library

  2. chfite commented on May 8, 2024

    @chfite
    Author

    @julian-belina I ended up following the direction of #450 which identifies this issue. @riley-brady mentions there he got a similar version error when importing proplot. Seems like it's all tied to incompatibility with newer matplotlib versions? I guess I am still not sure how this all ties back to the cartopy error above, but I am no developer by any means. I ran pip install git+https://github.com/proplot-dev/proplot.git and it seems that it downgraded my matplotlib to 3.5.3 and my proplot to 0.9.5, and things at least appear to be working for now...hopefully a full resolution is found for future versions.

  3. cvanelteren commented on Jul 30, 2024

    @cvanelteren

    A solution is being worked on #459

  4. cvanelteren commented on Aug 16, 2024

    @cvanelteren

    Fixed with #459 (comment)

  5. riley-brady commented on Aug 18, 2024

    @riley-brady

    Please see #459! Until this gets merged in and released as an official version, you can install proplot via the following command to have compatibility with modern python versions and modern versions of matplotlib, cartopy, etc.

    pip install git+https://github.com/proplot-dev/proplot.git@refs/pull/459/head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions