1

I am having trouble importing cartopy in a newly created conda environment. I installed cartopy with

conda install -c conda-forge cartopy

but when I try to import it I run into the following error:

ImportError: libgeos_c.so.1: cannot open shared object file: No such file or directory.

I do have libgeos in my enviroment lib directory, but still it doesn't work.

I tried doing what is suggested here: https://github.com/matplotlib/basemap/issues/302 and manually adding the library path :

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

but still not working. I don't know what else to do. It was working just fine before, but after I had to reinstall miniconda because of another issue I was having, I haven't been able to install cartopy.

I'm using conda 4.9.2 and python 3.9.1.

paulo
  • 43
  • 4
  • Could you please try creating a new environment (`conda create -n foo -c conda-forge cartopy`)? And ensure that all packages come from Conda Forge. One should not have to mess with env vars, especially not forcing something outside the environment to be prioritized. – merv Apr 11 '23 at 11:23

1 Answers1

0

Around December 2022, there were some changes with a cartopy dependency shapely, a solution that worked for me was found in the following stackoverflow answer: Getting "AttributeError: module 'shapely.geos' has no attribute 'lgeos'"

For newer version of Conda 23.7.2, I have the following dependencies working. However best to update your code to support newer versions of cartopy.

channels:
  - conda-forge
dependencies:
  - cartopy=0.18.0
  - geopy=2.2.0
  - python=3.9
  - pip=23.2.1
  - pip:
    - shapely==1.8.5
zerocog
  • 1,703
  • 21
  • 32