Apparently, it turned out that upgrading plotly version solved the problem. To upgrade plotly, I simply run the following codes to check the plotly version.

import plotly
plotly.__version__

That gave me the output of version of plotly as '5.11.0'. Then I upgraded the plotly version to '5.11.0' by writing the following code:

pip install plotly==5.11.0
Answer from S. Mandal on Stack Overflow
๐ŸŒ
Plotly
plotly.com โ€บ python โ€บ plotly-express
Plotly express in Python
import plotly.express as px df = px.data.tips() fig = px.bar(df, x="sex", y="total_bill", color="smoker", barmode="group", facet_row="time", facet_col="day", category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]}) fig.show()
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-plotly-tutorial
Plotly tutorial - GeeksforGeeks
July 23, 2025 - With px.line each data position is represented as a vertex (which location is given by the x and y columns) of a polyline mark in 2D space. ... import plotly.express as px df = px.data.iris() # plotting the line chart fig = px.line(df, x="species", ...
Discussions

python - Why am I getting error message as "ModuleNotFoundError: No module named 'plotly.express" while it was working before? - Stack Overflow
I'm having this bizarre experience; I'm re-running a code to plot a geographical graph using Plotly and use import plotly.express as px but it gives me the error message saying that " More on stackoverflow.com
๐ŸŒ stackoverflow.com
Plotly Express cannot open a local website page
I had the same issue in Edge and I think I was able to fix it. I discovered that if I clicked the URL and hit enter while it was trying to load, it would immediately load. This seems to indicate that Edge was interrupting the rendering process with something else. In "Cookies and site data" settings, toggle off "Preload pages for faster browsing ..." Cleared it right up for me. More on reddit.com
๐ŸŒ r/learnpython
10
0
September 16, 2021
python - How to save plotly express plot into a html or static image file? - Stack Overflow
This will give you a html file of a plotly express bar chart with the name lifeExp in a desired folder. Remember import plotly and not only import plotly.express as px. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Why am I getting error message as "ModuleNotFoundError: No module named 'plotly.express" while it was working before?
Apparently, it turned out that upgrading plotly version solved the problem. To upgrade plotly, I simply run the following codes to check the plotly version. import plotly plotly.__version__ That gave me the output of version of plotly as '5.11.0'. Then I upgraded the plotly version to '5.11.0' by writing the following code: pip install plotly==5.11.0 More on reddit.com
๐ŸŒ r/learnpython
2
1
November 22, 2022
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ plotly-express
plotly-express
JavaScript is disabled in your browser. Please enable JavaScript to proceed ยท A required part of this site couldnโ€™t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
๐ŸŒ
Plotly
plotly.com โ€บ python โ€บ getting-started
Getting started with plotly in Python
import plotly.express as px fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.show() or using FigureWidget objects. In [5]: import plotly.express as px fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) import plotly.graph_objects as go fig_widget ...
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-plotly-express-tutorial
Python Plotly Express Tutorial: Unlock Beautiful Visualizations | DataCamp
March 21, 2023 - import plotly.express as px fig = px.plotting_function( dataframe, x='column-for-xaxis', y='column-for-yaxis', title='Title For the Plot', width=width_in_pixels, height=height_in_pixels ) fig.show()
๐ŸŒ
GitHub
github.com โ€บ plotly โ€บ plotly.py โ€บ blob โ€บ main โ€บ doc โ€บ python โ€บ plotly-express.md
plotly.py/doc/python/plotly-express.md at main ยท plotly/plotly.py
import plotly.express as px df = px.data.iris() fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", marginal_y="violin", marginal_x="box", trendline="ols", template="simple_white") fig.show()
Author ย  plotly
Find elsewhere
๐ŸŒ
Codefinity
codefinity.com โ€บ courses โ€บ v2 โ€บ fb11bab5-fb60-4952-b6ba-f2a6635706b1 โ€บ f9a2535c-b02e-45d1-9cb2-4963aa0e64d4 โ€บ 0ffa025c-bed0-4188-b16c-3d19a5542933
Learn Getting Started with Plotly Express | Section
To understand how this scatter plot is created, start by importing the plotly.express module as px. Next, prepare the data you want to visualize; here, two Python lists, x and y, represent the coordinates of the points.
๐ŸŒ
Kaggle
kaggle.com โ€บ code โ€บ alsaniipe โ€บ scatter-plots-with-plotly-express โ€บ notebook
Scatter plots with Plotly Express
Checking your browser before accessing www.kaggle.com ยท Click here if you are not automatically redirected after 5 seconds
๐ŸŒ
Python Graph Gallery
python-graph-gallery.com โ€บ plotly
Plotly
In the following code, just 2 lines of code are needed to create an interactive bar chart, using the function px.bar(). # import the plotly express library import plotly.express as px # Some dummy data categories = ['A', 'B', 'C', 'D', 'E'] values = [15, 22, 18, 12, 28] # Plot fig = px.bar( x=categories, y=values, ) fig.show() In contrast, the Plotly Graph Objects API presents a finer level of control and customization within the Plotly framework.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ plotly express cannot open a local website page
r/learnpython on Reddit: Plotly Express cannot open a local website page
September 16, 2021 -

I am using python 3.9 and IDLE. I am trying to plot a simple graph and to visualize it on my Chrome browser. Below are two implementations. The first implementation works fine and it displays the graph interactively on a local web page.

The second implementation opens a web page that points to an IP adress http://127.0.0.1:59932/ and does not display the graph. After a while it comes with a message: This site canโ€™t be reached.

Can someone explain why the second implementation goes to the http://127.0.0.1:59932/ address and not to a temorary local address of the plot that the library could create. Please suggest how to fix it. Thanks.

First implementation:

import plotly.express as px
fig =px.scatter(x=range(10), y=range(10))
fig.write_html("C:/Users/Jim/example.html", auto_open = True)

Second implementation:

import plotly.express as px
fig =px.scatter(x=range(10), y=range(10))
fig.show()
๐ŸŒ
Python-Fiddle
python-fiddle.com โ€บ tutorials โ€บ plotly-scatter
Creating and Customizing Scatter Plots in Plotly
import plotly.graph_objs as go import plotly.express as px # Sample data x = [0, 1, 2, 3, 4, 5] y = [0, 1, 4, 9, 16, 25] # Create a Scatter plot fig = go.Figure(data=go.Scatter(x=x, y=y, mode='markers')) fig.update_layout( title='Basic Scatter Plot', xaxis_title='X-axis', yaxis_title='Y-axis' ...
๐ŸŒ
Posit
shiny.posit.co โ€บ py โ€บ components โ€บ outputs โ€บ plot-plotly
Plot (Plotly) โ€“ Shiny for Python
import plotly.express as px from palmerpenguins import load_penguins from shiny.express import input, ui from shinywidgets import render_widget penguins = load_penguins() ui.input_slider("n", "Number of bins", 1, 100, 20) @render_widget def plot(): scatterplot = px.histogram( data_frame=penguins, x="body_mass_g", nbins=input.n(), ).update_layout( title={"text": "Penguin Mass", "x": 0.5}, yaxis_title="Count", xaxis_title="Body Mass (g)", ) return scatterplot
๐ŸŒ
Panel
panel.holoviz.org โ€บ reference โ€บ panes โ€บ Plotly.html
Plotly โ€” Panel v1.8.10
import pandas as pd import panel as pn import plotly.express as px pn.extension("plotly") data = pd.DataFrame([ ('Monday', 7), ('Tuesday', 4), ('Wednesday', 9), ('Thursday', 4), ('Friday', 4), ('Saturday', 4), ('Sunday', 4)], columns=['Day', 'Orders'] ) fig_responsive = px.line(data, x="Day", y="Orders") fig_responsive.update_traces(mode="lines+markers", marker=dict(size=10), line=dict(width=4)) fig_responsive.layout.autosize = True responsive = pn.pane.Plotly(fig_responsive, height=300) pn.Column('## A responsive plot', responsive, sizing_mode='stretch_width') You can set the Plotly configuration options via the config parameter.
๐ŸŒ
Kanaries
docs.kanaries.net โ€บ topics โ€บ Plotly โ€บ plotly-express
Plotly Express: Clearly Explained โ€“ Kanaries
August 17, 2023 - You can import Plotly Express into Python using the following line of code: import plotly.express as px.
๐ŸŒ
101workbook
datascience.101workbook.org โ€บ 08-visualization โ€บ 02-graphs โ€บ 02-python โ€บ 02-intro-to-plotly-graphs
Introduction to Plotly - Data Science Workbook
3 weeks ago - Open the file in the selected CLI text editor (Nano, Vim, mcedit, etc.) or VSC editor with GUI and go to Plotly import section in this tutorial. In the terminal window execute the command provided below to start a new JupyterLab session (assuming ...
Top answer
1 of 7
70

Updated answer:

With newer versions of plotly, static Image export in Python is a breeze. Just make sure to install kaleido using:

pip install -U kaleido

or, for Anaconda:

conda install -c conda-forge python-kaleido

And then run

fig.write_image("yourfile.png") 

Filetypes such as .jpeg and .pdf are also available options.

Producing an individual html file is still very easy:

Just use plotly.offline.plot(fig, filename='C:/plotlyplots/canada_offline.html')

This will give you a html file of a plotly express bar chart with the name lifeExp in a desired folder. Remember import plotly and not only import plotly.express as px.

Complete code:

# imports
import plotly
import plotly.express as px

# data
df = px.data.gapminder().query("continent=='Oceania'")

# plotly express bar chart
fig = px.line(df, x="year", y="lifeExp", color='country')

# html file
plotly.offline.plot(fig, filename='C:/plotlyplots/lifeExp.html')

Plot:

File as it appears in the foler:

From here you can open the file in any browser or any other way you want.

Here's the content as it is displayed using Notepad++

If you don't mind a bit of manual labor, you dan save a .png version using the toolbar:


Old answer for static images:

Producing a static image automatically is a bit mote tricky.

Take a look at Static Image Export in Python if you prefer that to html.

I like to use the approach including orca that can produce a variety of image files. I haven't found any other way to install it other than using npm which is installed with node.js If you get that in order, you only have to go run the following to get it up and running (I'm on Windows):

npm install -g [email protected] orca

pip install psutil requests

Then you can change the last line in the snippet above with fig.write_image("C:/plotlyplots/lifeExp.png") to produce a .png file.

2 of 7
13

Adding to @vestland 's answer about saving to HTML, another way to do it according to the documentation would be:

import plotly.express as px

# a sample scatter plot figure created
fig = px.scatter(x=range(10), y=range(10))
fig.write_html("path/to/file.html")

You can read about it further (controlling size of the HTML file) here: Interactive HTML Export in Python

๐ŸŒ
PYTHON CHARTS
python-charts.com โ€บ home โ€บ correlation โ€บ scatter plot in plotly
Scatter plot in plotly | PYTHON CHARTS
October 4, 2022 - import plotly.express as px fig = px.scatter(x = [0, 1, 2, 3, 4, 5], y = [16, 8, 4, 2, 1, 0]) # Alternative: data from pandas data frame # import pandas as pd # df = pd.DataFrame({'x': [0, 1, 2, 3, 4, 5], # 'y': [16, 8, 4, 2, 1, 0]}) # Scatter ...
๐ŸŒ
Programming Historian
programminghistorian.org โ€บ en โ€บ lessons โ€บ interactive-visualization-with-plotly
Creating Interactive Visualizations with Plotly | Programming Historian
December 13, 2023 - Plotly Express (plotly.express, usually imported as px) is an accessible, high-level interface for creating data visualizations, offering around 30 different graph types. The module provides functions which create figures in just one line of code (although more lines are required for certain ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-create-a-bar-plot-with-plotly-express-in-python
How to create a bar plot with Plotly Express in Python
Lines 2โ€“3: import the required libraries for the code: plotly.express as px for creating the density heatmap plot, and pandas as pd for handling data in a DataFrame.