Hi all, I am new to Plotly and ran into an issue that I am unable to solve.
I was using ROSS - Rotordynamic Open Source Software, that uses Plotly for its interactive graphics output, in Jupyterlab on Windows 11. Initially everything worked fine, but somehow I meshed something up and now the graphics are not rendered anymore. I already uninstalled and reinstalled all packages, created a separate environment and uninstalled and reinstalled Python.
Whatever I try to render using Plotly, I basically get the same error that I also get after just running this piece of code:
import plotly.io as pio
pio.renderers
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[18], line 2
1 import plotly.io as pio
----> 2 pio.renderers
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\_plotly_utils\importers.py:36, in relative_import.<locals>.__getattr__(import_name)
34 rel_module = ".".join(rel_path_parts[:-1])
35 class_name = import_name
---> 36 class_module = importlib.import_module(rel_module, parent_name)
37 return getattr(class_module, class_name)
39 raise AttributeError(
40 "module {__name__!r} has no attribute {name!r}".format(
41 name=import_name, __name__=parent_name
42 )
43 )
File ~\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py:90, in import_module(name, package)
88 break
89 level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:935, in _load_unlocked(spec)
File <frozen importlib._bootstrap_external>:995, in exec_module(self, module)
File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\plotly\io\_renderers.py:9
5 from packaging.version import Version
7 from plotly import optional_imports
----> 9 from plotly.io._base_renderers import (
10 MimetypeRenderer,
11 ExternalRenderer,
12 PlotlyRenderer,
13 NotebookRenderer,
14 KaggleRenderer,
15 AzureRenderer,
16 ColabRenderer,
17 JsonRenderer,
18 PngRenderer,
19 JpegRenderer,
20 SvgRenderer,
21 PdfRenderer,
22 BrowserRenderer,
23 IFrameRenderer,
24 SphinxGalleryHtmlRenderer,
25 SphinxGalleryOrcaRenderer,
26 CoCalcRenderer,
27 DatabricksRenderer,
28 )
29 from plotly.io._utils import validate_coerce_fig_to_dict
31 ipython = optional_imports.get_module("IPython")
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\plotly\io\_base_renderers.py:9
6 from os.path import isdir
8 from plotly import utils, optional_imports
----> 9 from plotly.io import to_json, to_image, write_image, write_html
10 from plotly.io._orca import ensure_server
11 from plotly.io._utils import plotly_cdn_url
File <frozen importlib._bootstrap>:1412, in _handle_fromlist(module, fromlist, import_, recursive)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\_plotly_utils\importers.py:36, in relative_import.<locals>.__getattr__(import_name)
34 rel_module = ".".join(rel_path_parts[:-1])
35 class_name = import_name
---> 36 class_module = importlib.import_module(rel_module, parent_name)
37 return getattr(class_module, class_name)
39 raise AttributeError(
40 "module {__name__!r} has no attribute {name!r}".format(
41 name=import_name, __name__=parent_name
42 )
43 )
File ~\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py:90, in import_module(name, package)
88 break
89 level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\plotly\io\_kaleido.py:10
7 try:
8 from kaleido.scopes.plotly import PlotlyScope
---> 10 scope = PlotlyScope()
12 # Compute absolute path to the 'plotly/package_data/' directory
13 root_dir = os.path.dirname(os.path.abspath(plotly.__file__))
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\kaleido\scopes\plotly.py:64, in PlotlyScope.__init__(self, plotlyjs, mathjax, topojson, mapbox_access_token, debug, tmp_path, **kwargs)
62 if tmp_path:
63 temp_args = dict(dir=self.tmp_path)
---> 64 elif "snap" in path:
65 temp_path = Path.home()
66 if self.debug:
TypeError: argument of type 'NoneType' is not iterable
When it is attempted to render some actual graphics in Ross rotordynamics, the code that should be passed to the renderer is displayed after the error that is similar to the one displayed above.
Figure({
'data': [{'hoverinfo': 'none',
'line': {'color': 'black', 'dash': 'dashdot', 'width': 3.0},
'mode': 'lines',
'opacity': 0.7,
'showlegend': False,
'type': 'scatter',
'x': [-0.30000000000000004, 1.7999999999999998],
'y': [0, 0]},
{'hoverinfo': 'none',
'marker': {'color': '#ffcc99', 'line': {'color': 'black', 'width': 1.0}, 'opacity': 0.7, 'size': 20},
'mode': 'markers+text',
'showlegend': False,
'text': [0, 1, 2, 3, 4, 5, 6],
'type': 'scatter',
'x': [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5],
'y': array([0., 0., 0., 0., 0., 0., 0.])},
{'customdata': [[0, 0.05, 0.0, 0.05, 0.0, 0.25, 'Steel'], [0, 0.05,
0.0, 0.05, 0.0, 0.25, 'Steel'], [0, 0.05, 0.0, 0.05,
0.0, 0.25, 'Steel'], [0, 0.05, 0.0, 0.05, 0.0, 0.25,
'Steel'], [0, 0.05, 0.0, 0.05, 0.0, 0.25, 'Steel'],
[0, 0.05, 0.0, 0.05, 0.0, 0.25, 'Steel'], [0, 0.05,
0.0, 0.05, 0.0, 0.25, 'Steel'], [0, 0.05, 0.0, 0.05,
0.0, 0.25, 'Steel'], [0, 0.05, 0.0, 0.05, 0.0, 0.25,
'Steel'], [0, 0.05, 0.0, 0.05, 0.0, 0.25, 'Steel']],
'fill': 'toself',
... <cut>
My configuration is this:
(ross) C:\Users\xxx\AppData\Local\Programs\Python\Python312\ross\Scripts>jupyter --version
Selected Jupyter core packages...
IPython : 8.29.0
ipykernel : 6.29.5
ipywidgets : 8.1.5
jupyter_client : 8.6.3
jupyter_core : 5.7.2
jupyter_server : 2.14.2
jupyterlab : 4.2.6
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : 7.2.2
qtconsole : not installed
traitlets : 5.14.3
Does anyone have a suggestion how I can fix this? Maybe reset everything related to Plotly and the rendering?