8

I installed Christoph Gohlke's prebuilt wheel Cartopy‑0.20.2‑cp39‑cp39‑win_amd64.whl using pip in an active virtual environment. The environment is using Python 3.9.5. When trying to import Cartopy I get the error message below. This used to work before and now it no longer works and I can't figure out why. Does anyone know what the issue could be or what I'm missing?

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 import cartopy
      2 import cartopy.crs as ccrs
      3 import cartopy.io.img_tiles as cimgt

File ~\Downloads\GitHub\Project\venv\lib\site-packages\cartopy\__init__.py:110, in <module>
    105     pass
    108 # Commonly used sub-modules. Imported here to provide end-user
    109 # convenience.
--> 110 import cartopy.crs
    111 import cartopy.feature

File ~\Downloads\GitHub\Project\venv\lib\site-packages\cartopy\crs.py:27, in <module>
     24 from pyproj.exceptions import ProjError
     25 from shapely.prepared import prep
---> 27 import cartopy.trace
     30 try:
     31     # https://github.com/pyproj4/pyproj/pull/912
     32     from pyproj.crs import CustomConstructorCRS as _CRS

ImportError: DLL load failed while importing trace: The specified module could not be found.
2
  • 9
    Install shapely and pyproj from the same site.
    – cgohlke
    Mar 22, 2022 at 1:55
  • I had the same shapely and pyproj versions installed via pip but when I used --force-reinstall it worked. Mar 22, 2022 at 12:14

1 Answer 1

15

As mentioned by cgohlke in the comments, installing the wheels of shapely and pyproj from his website solves the issue.

If the libraries are already installed, use --force-reinstall to overwrite the existing installations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.