0
votes

I would like to import the module cartopy.io.img_tiles using:

import cartopy.io.img_tiles as cimgt

I have Cartopy 0.16.0 installed via Anaconda on Python 3.6. However, the string above yields:

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Me/Test.py", line 18, in import cartopy.io.img_tiles as cimgt

File "C:\ProgramData\Anaconda3\lib\site-packages\cartopy\io\img_tiles.py", line 32, in from PIL import Image

File "C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py", line 58, in from . import _imaging as core

ImportError: DLL load failed: The specified module could not be found.

I cannot figure out how to get the package to work. Cartopy is updated to its latest version and I cannot find out how to import the module or install it (using pip). I've tried multiple solutions, such as this and this. I'm probably overlooking something, but is there a simple way to get the module to work?

1
Could you provide the full traceback please? We don't have the detail on which DLL it is missing. - pelson
Given you are using anaconda, did you consider installing cartopy via conda-forge? It is the preferred installation mechanism for cartopy. conda install -c conda-forge cartopy - pelson
It returns: # All requested packages already installed. - A T
Thanks for updating. So you presumably can't import PIL.Image. That package comes from pillow on conda-forge (github.com/conda-forge/pillow-feedstock/blob/master/recipe/…). - pelson
After restarting the Spyder IDE it suddenly worked. Thank you! - A T

1 Answers

0
votes

Curiously enough, I do not know why the program started to work. Below, the steps I took are found. Special thanks to pelson for his comments.

1) I've updated the pillow package from version 5.0.0 to version 5.1.0, using conda update pillow

2) This caused the program to return C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py:82: RuntimeWarning: The _imaging extension was built for another version of Pillow or PIL: Core version: 5.1.0 Pillow version: 5.0.0 warnings.warn(str(v), RuntimeWarning)

3) Then, I downgraded the pillow package from 5.1.0 to 5.0.0 using conda install pillow=5.0.0

4) After restarting the Spyder IDE, the program suddenly worked.