I recently updated my environment and get the following error on importing cartopy
:
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-b0688681af7f> in <module> 12 import matplotlib.pyplot as plt 13 ---> 14 import cartopy.crs as ccrs 15 from cartopy.util import add_cyclic_point 16 import cmocean /glade/work/mclong/miniconda3/envs/krill/lib/python3.7/site-packages/cartopy/__init__.py in <module> 94 # Commonly used sub-modules. Imported here to provide end-user 95 # convenience. ---> 96 import cartopy.crs 97 import cartopy.feature # noqa: F401 (flake8 = unused import) /glade/work/mclong/miniconda3/envs/krill/lib/python3.7/site-packages/cartopy/crs.py in <module> 34 import six 35 ---> 36 from cartopy._crs import (CRS, Geodetic, Globe, PROJ4_VERSION, 37 WGS84_SEMIMAJOR_AXIS, WGS84_SEMIMINOR_AXIS) 38 from cartopy._crs import Geocentric # noqa: F401 (flake8 = unused import) ImportError: libproj.so.19: cannot open shared object file: No such file or directory
Has anyone encountered this? Solutions?
I am on somewhat up-to-date versions of cartopy
and proj
and things seem to work fine ( I tested the import)
$ conda list cartopy # packages in environment at /glade/work/abanihi/softwares/miniconda3/envs/analysis: # # Name Version Build Channel cartopy 0.18.0 py37h4b180d9_0 conda-forge abanihi at casper26 in ~ $ conda list proj # packages in environment at /glade/work/abanihi/softwares/miniconda3/envs/analysis: # # Name Version Build Channel proj 7.0.0 h966b41f_4 conda-forge pyproj 2.6.1.post1 py37h34dd122_0 conda-forge
I am curious... Did you pin your proj
and pyproj
versions? They are a little outdated:
abanihi at casper26 in ~ $ conda list cartopy # packages in environment at /glade/work/mclong/miniconda3/envs/krill: # # Name Version Build Channel cartopy 0.18.0 py37h4b180d9_0 conda-forge abanihi at casper26 in ~ $ conda list proj # packages in environment at /glade/work/mclong/miniconda3/envs/krill: # # Name Version Build Channel proj 6.3.1 hc80f0dc_1 conda-forge pyproj 2.5.0 py37he3cd046_1 conda-forge
no, I did not pin my proj
and pyproj
versions, but I bet that this is the problem. I don't include them in my specific list of dependencies.
Here's the environment: https://github.com/matt-long/krill-cesm-le/blob/master/environment/environment.yml
Can you suggest a modification?
Can you suggest a modification?
I am looking into it
i am inspecting the environment to see what packages may be restricting pyproj
and proj
to be updated
many thanks!
Anytime!
Are you using this environment file: https://github.com/matt-long/krill-cesm-le/blob/master/environment/environment.yml?
yes
I happened to have a krill
environment. I tried updating it with conda env update -f environment/environment.yml
and I noticed that proj
and pyproj
versions didn't change i.e. before and after the update:
$ conda list proj # packages in environment at /glade/work/abanihi/softwares/miniconda3/envs/krill: # # Name Version Build Channel proj 7.0.0 h966b41f_3 conda-forge pyproj 2.6.0 py37h34dd122_1 conda-forge
I'd recommend updating the environment file with the following:
- cartopy >= 0.18.0 - proj >= 7.0.0 - pyproj >= 2.6.0
thanks, I'll try it
this seems to have fixed my import error
thanks!
Awesome :tada:
@Matt Long , looks like this happened a while ago for you, but do you recall how you resolved it? This exact thing just happened to me.
Matt Long said:
I recently updated my environment and get the following error on importing
cartopy
:--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-b0688681af7f> in <module> 12 import matplotlib.pyplot as plt 13 ---> 14 import cartopy.crs as ccrs 15 from cartopy.util import add_cyclic_point 16 import cmocean /glade/work/mclong/miniconda3/envs/krill/lib/python3.7/site-packages/cartopy/__init__.py in <module> 94 # Commonly used sub-modules. Imported here to provide end-user 95 # convenience. ---> 96 import cartopy.crs 97 import cartopy.feature # noqa: F401 (flake8 = unused import) /glade/work/mclong/miniconda3/envs/krill/lib/python3.7/site-packages/cartopy/crs.py in <module> 34 import six 35 ---> 36 from cartopy._crs import (CRS, Geodetic, Globe, PROJ4_VERSION, 37 WGS84_SEMIMAJOR_AXIS, WGS84_SEMIMINOR_AXIS) 38 from cartopy._crs import Geocentric # noqa: F401 (flake8 = unused import) ImportError: libproj.so.19: cannot open shared object file: No such file or directory
Has anyone encountered this? Solutions?
Something like this is usually an environment conflict or other mismatch of dependencies. Are you using conda? Can you activate the environment and share the output of conda list
? Sometimes a conda update --all
might get you there, depending on how complex your environment is.
Last updated: May 16 2025 at 17:14 UTC