0

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?

A T
  • 281
  • 3
  • 11
  • Could you provide the full traceback please? We don't have the detail on which DLL it is missing. – pelson Jun 18 '18 at 08:11
  • 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 Jun 18 '18 at 08:12
  • It returns: # All requested packages already installed. – A T Jun 18 '18 at 08:18
  • Thanks for updating. So you presumably can't ``import PIL.Image``. That package comes from ``pillow`` on conda-forge (https://github.com/conda-forge/pillow-feedstock/blob/master/recipe/meta.yaml#L34). – pelson Jun 18 '18 at 08:27
  • I've updated the PIL package. Now the program returns: `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)` – A T Jun 18 '18 at 08:48
  • 1
    After restarting the Spyder IDE it suddenly worked. Thank you! – A T Jun 18 '18 at 08:59
  • I know it feels a little bit awkward, but would you mind answering your own question with the steps you took (even if they aren't exactly reproducible)? That way we can see that there is at least an answer to the problem you had. Thanks! – pelson Jun 19 '18 at 04:10

1 Answers1

0

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.

A T
  • 281
  • 3
  • 11