plotly

ModuleNotFoundError No module named ‘plotly.’

Plotly is a free and open-source plotting library. It is a popular tool developers use to create highly accurate, interactive, and beautiful plots. It supports various plot types suitable for financial, statistical, and scientific fields.

Despite its popularity and features, plotly is unavailable in the default Python installation. Hence, you will face the “ModuleNotFoundError: No Module named plotly” error when importing the module.

This tutorial will show you how to install the Plotly package in your Python environment and resolve the ModuleNotFoundError when importing it.

Step 1: Installing pip

As mentioned, Plotly does not come installed with the default Python installer. Hence, to get plotly running, we need to install it manually.

We can do this using the pip package manager. Depending on the system, pip may not be installed.

If you already have pip installed and running on your system, feel free to skip the second section of this guide.

On Debian and any Debian-based distributions, run the command as shown:

$ sudo apt-get install python3-pip -y

The command above will install pip for Python3 on your system. For example, if you are running Python 2. x, run the command as shown:

$ sudo apt-get install python-pip -y

On CentOS and REHL, run the command:

$ sudo yum install python-pip

Or

$ sudo yum groupinstall 'Development Tools'

On Arch:

$ sudo pacman -Syu python-pip

Or

$ sudo pacman -Syu python2-pip

Step 2: Install Plotly

Once you have pip installed on your system, we can import Plotly by running the command:

$ pip install plotly

If you are running Python3, run the command:

$ pip3 install plotly

The command above should download and install Plotly.

You can verify this by importing the package as shown:

>>> import plotly.express as px

>>>

Running the import statement above in the Python interpreter should run without errors.

You can check the version by running:

>>> import plotly

>>> plotly.__version__

'5.9.0'

The code above should return the installed Plotly version.

Keep in mind that Plotly requires Pandas and NumPy installed on your system.

Closing

This article discussed how to solve the modulenotfounderror: no module named ‘mysqldb’ error in Python.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list