Black Lives Matter. Please consider donating to Black Girls Code today.

Troubleshooting in Python

How to troubleshoot import and rendering problems in Plotly with Python.

New to Plotly?

Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

Version Problems

In order to follow the examples in this documentation, you should have the latest version of plotly installed (4.x), as detailed in the Getting Started guide. This documentation (under is incompatible with plotly version 3.x, for which the documentation is available under

Import Problems

Most import problems or AttributeErrors can be traced back to having multiple versions of plotly installed, for example once with conda and once with pip. It's often worthwhile to uninstall with both methods before following the Getting Started instructions from scratch with one or the other. You can run the following commands in a terminal to fully remove plotly before installing again:

$ conda uninstall plotly
$ pip remove plotly

Jupyter Notebook Classic Problems

The classic Jupyter Notebook (i.e. launched with jupyter notebook) sometimes suffers from a problem whereby if you close the window and reopen it, your plots render as blank spaces.

The easiest solution is to force the notebook renderer to reload by calling"notebook") instead of just

If this problem is recurrent, you may safely run the following code in a Notebook (not in JupyterLab!) at any time and it should restore your figures (for example, you may put it at the top of your notebook for easy access):

import as pio

As a last resort, you can "Restart & Clear Output" from the Kernel menu and rerun your notebook.

JupyterLab Problems

In order to use plotly in JupyterLab, you must have the extensions installed as detailed in the Getting Started guide. Please note that the extension version matters: the extension versions in the Getting Started guide match the version of plotly at the top of the guide and so they should be installed together. Note also that these extensions are meant to work with JupyterLab 1.x and not 0.x.

If you are having problems in JupyterLab, a good first step is to check that you have the extensions installed by running uninstall/reinstall the extensions.

To list your current extensions, run the following command in a terminal shell:

$ jupyter labextension list

To uninstall your Plotly extensions, run the following commands in a terminal shell before reinstalling them by following the instructions in the Getting Started guide:

$ jupyter labextension uninstall jupyterlab-plotly
$ jupyter labextension uninstall plotlywidget

If you run into "out of memory" problems while installing the extensions, try running these commands before running jupyter labextension install...

# Avoid "JavaScript heap out of memory" errors during extension installation
# (OS X/Linux)
export NODE_OPTIONS=--max-old-space-size=4096
# (Windows)
set NODE_OPTIONS=--max-old-space-size=4096

...and these commands afterwards.

# Unset NODE_OPTIONS environment variable
# (OS X/Linux)
# (Windows)

What About Dash?

Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.

Learn about how to install Dash at

Everywhere in this page that you see, you can display the same figure in a Dash application by passing it to the figure argument of the Graph component from the built-in dash_core_components package like this:

import plotly.graph_objects as go # or as px
fig = go.Figure() # or any Plotly Express function e.g.
# fig.add_trace( ... )
# fig.update_layout( ... )

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([

app.run_server(debug=True, use_reloader=False)  # Turn off reloader if inside Jupyter