AllenInstitute / AllenSDK

code for reading and processing Allen Institute for Brain Science data
https://allensdk.readthedocs.io/en/latest/
Other
340 stars 150 forks source link

Matplotlib fails to import in fresh allensdk install in python 3.7 #2510

Closed egmcbride closed 2 years ago

egmcbride commented 2 years ago

Describe the bug I'm working with the VBN dataset, and everything works great with a fresh install of python 3.8 and pip install allensdk.

When I try the same with python=3.7, matplotlib fails to import. The install guide (https://allensdk.readthedocs.io/en/latest/install.html) says to use python 3.7 with the allensdk. Should this be updated to say python 3.8 is required?

To Reproduce import matplotlib.pyplot as plt

Expected behavior matplotlib to be imported

Actual Behavior

AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_6632\2089743655.py in 2 import numpy as np 3 import pandas as pd ----> 4 import matplotlib.pyplot as plt 5 import xarray as xr 6 import scipy.ndimage as ndi

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib\pyplot.py in 42 from matplotlib import docstring 43 from matplotlib.backend_bases import FigureCanvasBase, MouseButton ---> 44 from matplotlib.figure import Figure, figaspect 45 from matplotlib.gridspec import GridSpec, SubplotSpec 46 from matplotlib import rcParams, rcParamsDefault, get_backend, rcParamsOrig

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib\figure.py in 22 23 import matplotlib as mpl ---> 24 from matplotlib import docstring, projections 25 from matplotlib import version as _mpl_version 26

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib\projections__init__.py in 2 from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes 3 from .polar import PolarAxes ----> 4 from mpl_toolkits.mplot3d import Axes3D 5 6

~\AppData\Roaming\Python\Python37\site-packages\mpl_toolkits\mplot3d__init__.py in ----> 1 from .axes3d import Axes3D

~\AppData\Roaming\Python\Python37\site-packages\mpl_toolkits\mplot3d\axes3d.py in 45 @cbook._define_aliases({ 46 "xlim3d": ["xlim"], "ylim3d": ["ylim"], "zlim3d": ["zlim"]}) ---> 47 class Axes3D(Axes): 48 """ 49 3D axes object.

~\AppData\Roaming\Python\Python37\site-packages\mpl_toolkits\mplot3d\axes3d.py in Axes3D() 52 53 _axis_names = ("x", "y", "z") ---> 54 Axes._shared_axes["z"] = cbook.Grouper() 55 56 def init(

AttributeError: type object 'Axes' has no attribute '_shared_axes'

Error in callback <function _enable_matplotlib_integration..configure_once at 0x000001C0A81AE318> (for post_run_cell):


AttributeError Traceback (most recent call last) C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib_inline\backend_inline.py in configure_once(args) 215 # bugs may cause a circular import on Python 2 216 def configure_once(args): --> 217 activate_matplotlib(backend) 218 configure_inline_support(ip, backend) 219 ip.events.unregister('post_run_cell', configure_once)

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\IPython\core\pylabtools.py in activate_matplotlib(backend) 355 # when this function runs. 356 # So avoid needing matplotlib attribute-lookup to access pyplot. --> 357 from matplotlib import pyplot as plt 358 359 plt.switch_backend(backend)

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib\pyplot.py in 42 from matplotlib import docstring 43 from matplotlib.backend_bases import FigureCanvasBase, MouseButton ---> 44 from matplotlib.figure import Figure, figaspect 45 from matplotlib.gridspec import GridSpec, SubplotSpec 46 from matplotlib import rcParams, rcParamsDefault, get_backend, rcParamsOrig

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib\figure.py in 22 23 import matplotlib as mpl ---> 24 from matplotlib import docstring, projections 25 from matplotlib import version as _mpl_version 26

C:\Anaconda3\envs\allensdk_37_new\lib\site-packages\matplotlib\projections__init__.py in 2 from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes 3 from .polar import PolarAxes ----> 4 from mpl_toolkits.mplot3d import Axes3D 5 6

~\AppData\Roaming\Python\Python37\site-packages\mpl_toolkits\mplot3d__init__.py in ----> 1 from .axes3d import Axes3D

~\AppData\Roaming\Python\Python37\site-packages\mpl_toolkits\mplot3d\axes3d.py in 45 @cbook._define_aliases({ 46 "xlim3d": ["xlim"], "ylim3d": ["ylim"], "zlim3d": ["zlim"]}) ---> 47 class Axes3D(Axes): 48 """ 49 3D axes object.

~\AppData\Roaming\Python\Python37\site-packages\mpl_toolkits\mplot3d\axes3d.py in Axes3D() 52 53 _axis_names = ("x", "y", "z") ---> 54 Axes._shared_axes["z"] = cbook.Grouper() 55 56 def init(

AttributeError: type object 'Axes' has no attribute '_shared_axes'

Environment (please complete the following information):

aamster commented 2 years ago

@egmcbride can't reproduce this. In fact we have automated tests that run windows using python 3.7 that utilize matplotlib.

jsiegle commented 2 years ago

I have another issue with Python 3.7...executing cells in the latest version of VSCode only works when using ipykernel for Python 3.8+. Since Python 3.9 isn't supported yet, I can only use the AllenSDK in Python 3.8 environments. I think it would be helpful to have a note about this somewhere in the docs, to avoid potential installation headaches.