matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.59k stars 225 forks source link

Tornado overridden by tornadofake: disruption in JupyterLab #387

Closed consideRatio closed 3 years ago

consideRatio commented 3 years ago

@tsnow03 working in a modern version of JupyterLab reported the following behavior in a notebook, that seems to relate to #381.

In short, any package that is imported and that relies on some tornado import that follows having executed %matplotlib widgets will error.

%matplotlib widgets
import xarray
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_495/3735348000.py in <module>
----> 1 import xarray

/srv/conda/envs/notebook/lib/python3.9/site-packages/xarray/__init__.py in <module>
      1 import pkg_resources
      2 
----> 3 from . import testing, tutorial, ufuncs
      4 from .backends.api import (
      5     load_dataarray,

/srv/conda/envs/notebook/lib/python3.9/site-packages/xarray/tutorial.py in <module>
     11 import numpy as np
     12 
---> 13 from .backends.api import open_dataset as _open_dataset
     14 from .backends.rasterio_ import open_rasterio as _open_rasterio
     15 from .core.dataarray import DataArray

/srv/conda/envs/notebook/lib/python3.9/site-packages/xarray/backends/__init__.py in <module>
      4 formats. They should not be used directly, but rather through Dataset objects.
      5 """
----> 6 from .cfgrib_ import CfGribDataStore
      7 from .common import AbstractDataStore, BackendArray, BackendEntrypoint
      8 from .file_manager import CachingFileManager, DummyFileManager, FileManager

/srv/conda/envs/notebook/lib/python3.9/site-packages/xarray/backends/cfgrib_.py in <module>
     14     _normalize_path,
     15 )
---> 16 from .locks import SerializableLock, ensure_lock
     17 from .store import StoreBackendEntrypoint
     18 

/srv/conda/envs/notebook/lib/python3.9/site-packages/xarray/backends/locks.py in <module>
     11 
     12 try:
---> 13     from dask.distributed import Lock as DistributedLock
     14 except ImportError:
     15     DistributedLock = None

/srv/conda/envs/notebook/lib/python3.9/site-packages/dask/distributed.py in <module>
      9 
     10 try:
---> 11     from distributed import *
     12 except ImportError as e:
     13     if e.msg == "No module named 'distributed'":

/srv/conda/envs/notebook/lib/python3.9/site-packages/distributed/__init__.py in <module>
----> 1 from . import config  # isort:skip; load distributed configuration first
      2 from . import widgets  # isort:skip; load distributed widgets second
      3 import dask
      4 from dask.config import config
      5 from dask.utils import import_required

/srv/conda/envs/notebook/lib/python3.9/site-packages/distributed/config.py in <module>
      8 import dask
      9 
---> 10 from .compatibility import logging_names
     11 
     12 config = dask.config.config

/srv/conda/envs/notebook/lib/python3.9/site-packages/distributed/compatibility.py in <module>
     12 MACOS = sys.platform == "darwin"
     13 WINDOWS = sys.platform.startswith("win")
---> 14 TORNADO6 = tornado.version_info[0] >= 6

AttributeError: module 'tornadofake' has no attribute 'version_info'
ianhi commented 3 years ago

Hi @consideRatio what version of ipympl are you using? This should have been fixed by version 0.8.2 https://github.com/matplotlib/ipympl/releases/tag/0.8.2

consideRatio commented 3 years ago

Ah I see 0.8.1 was used, thanks, closing this as resolved!

Verified I had no such errors in 0.8.2!