Python Pandas

ImportError Plotly Express Requires Pandas to be Installed

Plotly is a free data visualization and graphing library that facilitates the creation of rich and interactive plots. It provides a plethora of plots suitable for a comprehensive collection of use cases including statistical plotting, scientific plots, etc.

However, you may face the error “ImportError Plotly Express requires pandas to be installed” when importing the Plotly Express.

An example case is shown in the following:

>>> import plotly.express as px

As we can see from the given screenshot, importing the Plotly Express returns an error.

Let us discuss why this error occurs and how we can resolve it in this short tutorial.

What Causes This Error?

If you are just starting with Plotly, you may think installing the Plotly package should have everything you need. While this is true when working with graph_objects, Plotly Express requires Pandas as a dependency.

Therefore, you need to install the Pandas before using Plotly Express.

Solution

As mentioned, Plotly Express requires Pandas as a dependency. Hence, you need to install the Pandas in your Python environment to resolve this issue.

Run the following command:

$ pip3 install pandas

If you are running the Python 2. x, install Pandas with the following command:

$ pip install pandas

If you are using Anaconda as the Python environment, you can use conda as follows:

$ conda install -c anaconda pandas

Once installed, you can test if the Plotly Express is working by running the following command:

>>> import plotly.express as px
>>>

Congratulations! You successfully solved the error.

Conclusion

This short tutorial shows you how to resolve the “ImportError Plotly express requires Pandas to be installed” error when importing the Plotly Express.

Thanks for reading!!

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