Last modified: Mar 25, 2025 By Alexander Williams
How to Install Plotly in Python Step by Step
Plotly is a powerful library for creating interactive visualizations in Python. This guide will help you install it easily.
Prerequisites
Before installing Plotly, ensure you have Python installed. You can check using python --version
in your terminal.
python --version
Python 3.9.7
If Python is not installed, download it from the official website. Also, ensure pip is up to date.
Install Plotly Using pip
The easiest way to install Plotly is using pip. Open your terminal or command prompt.
Run the following command to install Plotly:
pip install plotly
This will download and install the latest version of Plotly. Wait for the installation to complete.
Verify the Installation
After installation, verify it by importing Plotly in Python. Open a Python shell or script.
import plotly
print(plotly.__version__)
5.10.0
If you see the version number, Plotly is installed correctly. If not, check for errors.
Common Installation Issues
Sometimes, you may encounter issues like ModuleNotFoundError. This means Plotly is not installed.
If you face ModuleNotFoundError: No module named 'plotly', reinstall Plotly using pip.
For more help, read our guide on how to solve ModuleNotFoundError.
Install Plotly in Jupyter Notebook
If you use Jupyter Notebook, install Plotly directly in a cell using !pip install plotly
.
!pip install plotly
Restart the kernel after installation. This ensures the library is loaded correctly.
Install Plotly with Anaconda
For Anaconda users, install Plotly using conda. Run this command in the Anaconda Prompt.
conda install -c plotly plotly
This installs Plotly from the Plotly channel. It ensures compatibility with other Anaconda packages.
Create Your First Plot
Test Plotly by creating a simple plot. Copy the code below into your Python script.
import plotly.express as px
fig = px.bar(x=["A", "B", "C"], y=[1, 2, 3])
fig.show()
This code creates a bar chart. Run it to see the interactive visualization.
Conclusion
Installing Plotly in Python is simple with pip or conda. Follow the steps above to get started.
Plotly helps create stunning interactive charts. Now you’re ready to explore its full potential.
For more Python tips, check our other guides. Happy coding!