0

I'm trying to use OSMnx in binder but get an error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_120/2784735849.py in <module>
      1 import networkx as nx
----> 2 import osmnx as ox
      3 
      4 get_ipython().run_line_magic('matplotlib', 'inline')
      5 ox.config(log_console=True)

/srv/conda/envs/notebook/site-packages/osmnx/__init__.py in <module>
      1 """OSMnx init."""
      2 
----> 3 from ._api import *
      4 from ._version import __version__

/srv/conda/envs/notebook/site-packages/osmnx/_api.py in <module>
      1 """Expose most common parts of public API directly in `osmnx.` namespace."""
      2 
----> 3 from .bearing import add_edge_bearings
      4 from .bearing import orientation_entropy
      5 from .bearing import plot_orientation

/srv/conda/envs/notebook/site-packages/osmnx/bearing.py in <module>
      3 import warnings
      4 
----> 5 import matplotlib.pyplot as plt
      6 import networkx as nx
      7 import numpy as np

/srv/conda/envs/notebook/site-packages/matplotlib/__init__.py in <module>
    105 # cbook must import matplotlib only within function
    106 # definitions, so it is safe to import from it here.
--> 107 from . import _api, cbook, docstring, rcsetup
    108 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
    109 from matplotlib.cbook import mplDeprecation  # deprecated

/srv/conda/envs/notebook/site-packages/matplotlib/rcsetup.py in <module>
     22 import numpy as np
     23 
---> 24 from matplotlib import _api, animation, cbook
     25 from matplotlib.cbook import ls_mapper
     26 from matplotlib.colors import Colormap, is_color_like

/srv/conda/envs/notebook/site-packages/matplotlib/animation.py in <module>
     32 
     33 import numpy as np
---> 34 from PIL import Image
     35 
     36 import matplotlib as mpl

/srv/conda/envs/notebook/site-packages/PIL/Image.py in <module>
    112     # Also note that Image.core is not a publicly documented interface,
    113     # and should be considered private and subject to change.
--> 114     from . import _imaging as core
    115 
    116     if __version__ != getattr(core, "PILLOW_VERSION", None):

ImportError: cannot import name '_imaging'

This happens when I try to create my own binder, but also if I use the one from Geoff himself: https://mybinder.org/v2/gh/gboeing/osmnx-examples/main?urlpath=lab it occurs when running the first block for example in this example notebook: OSMnx features demo

Update: Using the previous version of OSMnx (1.0.1) 'solves' the issue (meaning with that version I don't get the error message)

Sanne Hombroek
  • 105
  • 1
  • 6
  • Possibly relevant: https://stackoverflow.com/questions/25340698/importerror-cannot-import-name-imaging – gboeing Oct 14 '21 at 19:34
  • In the meantime, the prior release works on Binder: https://mybinder.org/v2/gh/gboeing/osmnx-examples/v1.0.1?urlpath=lab – gboeing Oct 14 '21 at 19:38
  • I also came across that one, but couldn't figure out what to do. I also wasn't sure whether I should have mentioned this as an issue in Git, since it also didn't work with your example, but it's not part of the core of OSMnx of course. I used v1.0.1 now and it works! (also for my own created thing). Thanks again for replying and for the great package! – Sanne Hombroek Oct 17 '21 at 12:22
  • I'm confused. Is this resolved now by using osmnx 1.0.1? And maybe put a note in the post if the solution provided is adequate? It seems there's an issue with Pillow and and matplotlib's animation code trying to access `_imaging` whereas Pillow has decided to not allow that. But then why does osmnx 1.0.1 work? I wonder if pinning set versions of Pillow and/or matplotlib prior to the current ones to the `environment.yml` on osmnx-examples might help 1.1.1 work? – Wayne Oct 23 '21 at 20:05
  • I added an update to the question to explain that it works with V1.0.1. I'm not sure how to solve the actual issue (that's over my head I'm afraid..). – Sanne Hombroek Oct 25 '21 at 20:32
  • It appears that the latest releases of `pillow` and/or `matplotlib` have resolved this issue. – gboeing Nov 02 '21 at 19:52

0 Answers0