AutoViz: "AttributeError: module 'inspect' has no attribute 'ArgSpec'", thrown up by outdated holoviews version when used in Python 3.11 environment

Versions:

Python = 3.11 pandas = 1.5.3 (autoviz also needs updating to latest version of pandas - 2.1) numpy = 1.23.5 (autoviz also needs updating to latest version of numpy - 1.26) bokeh = 2.4.3 (udpating it to 3.* downgrades autoviz to 0.1.24) dash = 2.14.0

Error produced:

AttributeError                            Traceback (most recent call last)
Cell In[19], line 7
      4 np.bool = bool
      6 AV = AutoViz_Class()
----> 7 av = AV.AutoViz(filename='', sep=',', header=0, 
      8                 depVar='result', dfte=DATA1, 
      9                 lowess=False,
     10                 max_rows_analyzed=150000, max_cols_analyzed=100, 
     11                 verbose=1, chart_format='bokeh', #'html', #
     12                 #verbose=2, chart_format='html', # creates separate and very large files
     13                 save_plot_dir=None
     14                )

File ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Class.py:257, in AutoViz_Class.AutoViz(self, filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    255 ####################################################################################
    256 if chart_format.lower() in ['bokeh','server','bokeh_server','bokeh-server', 'html']:
--> 257     dft = AutoViz_Holo(filename, sep, depVar, dfte, header, verbose,
    258                 lowess,chart_format,max_rows_analyzed,
    259                     max_cols_analyzed, save_plot_dir)
    260 else:
    261     dft = self.AutoViz_Main(filename, sep, depVar, dfte, header, verbose,
    262                 lowess,chart_format,max_rows_analyzed,
    263                     max_cols_analyzed, save_plot_dir)

File ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:181, in AutoViz_Holo(filename, sep, depVar, dfte, header, verbose, lowess, chart_format, max_rows_analyzed, max_cols_analyzed, save_plot_dir)
    178         drawobj2 = draw_pair_scatters_hv(dfin, nums, problem_type, chart_format, dep,
    179                        classes, lowess, mk_dir, verbose)
    180         ls_objects.append(drawobj2)
--> 181 drawobj3 = draw_distplot_hv(dfin, cats, nums, chart_format, problem_type, dep, classes, mk_dir, verbose)
    182 ls_objects.append(drawobj3)
    183 ### kdeplot is the only time you send in ls_objects since it has to be returned with 2 objects ###

File ~\Python\venvs\eda311\Lib\site-packages\autoviz\AutoViz_Holo.py:722, in draw_distplot_hv(dft, cats, conti, chart_format, problem_type, dep, classes, mk_dir, verbose)
    720     return plot
    721 #######  This is where you call the widget and pass it the select_variable to draw a Chart #######
--> 722 dmap = hv.DynamicMap(select_widget,  kdims=['Select_categorical_var']).redim.values(
    723                                     Select_categorical_var=cats)
    724 ###########  This is where you put the Panel Together ############
    725 hv_panel = pn.panel(dmap)

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\core\spaces.py:923, in DynamicMap.__init__(self, callback, initial_items, streams, **params)
    919     raise TypeError(msg.format(objs = ', '.join('%r' % el for el in invalid)))
    921 super(DynamicMap, self).__init__(initial_items, callback=callback, streams=valid, **params)
--> 923 if self.callback.noargs:
    924     prefix = 'DynamicMaps using generators (or callables without arguments)'
    925     if self.kdims:

File ~\Python\venvs\eda311\Lib\site-packages\holoviews\core\spaces.py:640, in Callable.noargs(self)
    637 @property
    638 def noargs(self):
    639     "Returns True if the callable takes no arguments"
--> 640     noargs = inspect.ArgSpec(args=[], varargs=None, keywords=None, defaults=None)
    641     return self.argspec == noargs

AttributeError: module 'inspect' has no attribute 'ArgSpec'

To reproduce error:

Just run autoviz with following parameters:

from sklearn.datasets import fetch_california_housing

data = fetch_california_housing()
test = pd.concat([pd.DataFrame(data['data'], columns=data['feature_names']), pd.DataFrame(data['target'], columns=data['target_names'])], axis=1)

from autoviz import AutoViz_Class

AV = AutoViz_Class()
av = AV.AutoViz(filename='', sep=',', header=0, 
                depVar='MedHouseVal', 
                dfte=test, 
                lowess=False,
                max_rows_analyzed=150000, max_cols_analyzed=100, 
                verbose=1, chart_format='bokeh', 
                save_plot_dir=None
               )

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Comments: 26 (11 by maintainers)

Most upvoted comments

As indicated in https://github.com/AutoViML/AutoViz/issues/102#issuecomment-1890901228, the fix for this in HoloViews has been released in version 1.15.3. So you’ll need this version of HoloViews or an older one if you run your code with Python 3.11.

Since AutoViz pins HoloViews to 1.14.9 (this pin means holoviews >=1.14.9, <1.15.0):

https://github.com/AutoViML/AutoViz/blob/29046b6de71d7c559d2b0763a71a48a4521e0b59/setup.py#L30

@RNarayan73 you have a few solutions:

  • Update AutoViz to support newer versions of HoloViews. It might just require removing the pin, or it may require more work, I don’t know (HoloViews is usually pretty stable).
  • Force installing holoviews >=1.15.3 in your environment after installing AutoViz, and cross your fingers
  • Use Python <= 3.11