Skip to content

Compatibility issue with new version of plotly? #44

Description

@mm5631

Hi guys, getting the following error with the explorer module:

AttributeError                            Traceback (most recent call last)
<ipython-input-9-38c8dacf5299> in <module>
----> 1 explorer.correlation_plot()

~/machine_learning/.env/lib/python3.7/site-packages/lens/explorer.py in correlation_plot(self, include, exclude)
    311         """
    312         fig = plot_correlation(self.summary, include, exclude)
--> 313         self.plot_renderer(fig)
    314 
    315     def correlation(self, include=None, exclude=None):

~/machine_learning/.env/lib/python3.7/site-packages/lens/explorer.py in _render(fig, showlegend)
     44         raise ValueError(message)
     45     else:
---> 46         if not py.offline.__PLOTLY_OFFLINE_INITIALIZED:
     47             py.init_notebook_mode()
     48         return py.iplot(fig, **PLOTLY_KWS)

AttributeError: module 'plotly.offline.offline' has no attribute '__PLOTLY_OFFLINE_INITIALIZED'

I'm working in a python virtulaenv with the following setup

CPython 3.7.3

numpy 1.17.2
pandas 0.25.1
matplotlib 3.1.1
plotly 4.1.1
lens 0.4.5

system     : Linux
release    : 5.0.0-31-generic
machine    : x86_64
interpreter: 64bit

I believe the issue to be come from recent updates in the plotly library with the integration of plotly_express js initilization in the python package.

Quickfix that worked was simply removing the if statement in line 46 of explorer.py

45    else:
46        if not py.offline.__PLOTLY_OFFLINE_INITIALIZED: # remove
47            py.init_notebook_mode() # unindent
48        return py.iplot(fig, **PLOTLY_KWS)

Might be worth a pull request?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions