Requires pandas, but not documented?
I'm new to plotly. I installed plotly with pip install plotly==4.5.4 and when I tried to generate a graph, I got 'ImportError: Plotly express requires pandas to be installed.'
The getting-started page says "This package contains everything you need to write figures to standalone HTML files." I looked through the documentation, but couldn't find anywhere that said pandas was required, or how to install pandas.
To reproduce:
>>> import plotly.express as px
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ken/blog/corona/env/lib/python3.7/site-packages/plotly/express/__init__.py", line 12, in <module>
Plotly express requires pandas to be installed."""
ImportError: Plotly express requires pandas to be installed.
Maybe this is intentional (see #2125), but I think the documentation should be clearer. Automatically installing pandas would be even better.
Hi @shirriff thank you for reaching out. We want to limit the required dependencies of plotly, and pandas is only an optional dependency which is used in plotly.express only. That said, I totally agree that what happened to you us confusing, and we could
- update the documentation in places to mention this optional dependencies thing (scikit-image is also required for one of the figure factories for example)
- and possibly set up a greater dependency set which would install with
pip install "plotly[complete]", like what other packages do (https://docs.dask.org/en/latest/install.html, see https://github.com/dask/dask/blob/master/setup.py for how this is configured).
This could actually be a really great to contribute to plotly for someone interested. (@nicolaskruchten do you concur?)
Hi @emmanuelle
If you say that pandas is a dependency that is only used in plotly.express , wouldn't it be smarter to make plotly.express a separate project ?
Since plotly.express is part of the plotly project, You need pandas for plotly, right?
Our reasoning for not making it a hard dependency is that you can still use plotly.io and plotly.graph_objects to make a large number of charts, all without installing pandas or numpy etc.
By the way, i've got installed pandas, but i still get this error - http://joxi.ru/EA4DMDzipXPV0A
By the way, i've got installed pandas, but i still get this error - http://joxi.ru/EA4DMDzipXPV0A
I have the same problem.
@pnirtep and @neo-sirapat if you import pandas before you import plotly.express it works!
I had the same problem as @pnirtep and @neo-sirapat. I tried creating a new environment and installing pandas first, to no avail. I noticed a link to this URL in my traceback and after installing numPy version 1.19.3 I was able to run Plotly Express.
I really don't understand "the problem" that folks are reporting here... If you see the error ImportError: Plotly express requires pandas to be installed. then you need to install pandas. Are folks seeing this error even when pandas is installed?
@nicolaskruchten correct, the problem reported is that we are receiving the error after installing pandas.
@jason-danforth thanks for the explanation. This is a pretty different issue from the initial description at the top here but OK, we can work on figuring out what's happening.
Can you confirm that Pandas is fully and correctly installed in the same environment you're trying to access Plotly from when this happens? For example, in the same Python process as the one you're seeing the PX error in, what does this print out?
import pandas as pd
print(pd.__version__)
Can you also tell me about the way you're accessing Python? Via a virtualenv or conda? Which version of Python? Are you in a Jupyter notebook? Via Classic Notebook, JupyterLab or VSCode's extension? What operating system are you on? Etc :)
@nicolaskruchten no problem, though I just want to reiterate that I was able to resolve the issue by reverting to an earlier version of NumPy.
Pandas 1.1.5 I'm running code from the Windows command line in a virtual environment Python 3.8.3 Operating system: Windows 10 Pro Version 20H2 OS build 19042.630
Thanks! OK so if reverting numpy solves it then this is pretty unrelated to plotly... Basically it seems like in some cases pandas doesn't get correctly-enough loaded for plotly to use it?
Not exactly. I had no problems using either Pandas or NumPy, but could not run Plotly Express. After attempting to read through the discussion at that URL (and I'll be honest, I understood about 5% of it) I got that there is a larger problem for Windows users related a recent Windows Update and the latest version of Numpy, and that (I suspect) is what is causing the problem for Plotly users. The Microsoft team is anticipating a fix in late January, so you may have users with this problem for some time...
@jason-danforth It seems NumPy with latest RC version (1.20.0rc1) also work on Windows
Having the same problem even if pandas already installed.
Having the same problem even if pandas already installed.
I just figured out the issue which lies in the underline numpy package which is having some dependencies issues in the Win system. Check this link out.
I uninstalled numpy and installed 1.19.0 which solves the problem.
However I do agree that pandas should be a hard dependency as plotly uses it.
The underline error for me was missing libf77blas which ultimately fixed my issue. I've still not update numpy is still at 1.19.0 in my setup.
` Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.
import plotly.express as px Traceback (most recent call last): File "
", line 1, in File "/usr/local/lib/python3.7/dist-packages/plotly/express/init.py", line 12, in Plotly express requires pandas to be installed.""" ImportError: Plotly express requires pandas to be installed. import pandas Traceback (most recent call last): File " ", line 1, in File "/usr/local/lib/python3.7/dist-packages/pandas/init.py", line 17, in "Unable to import required dependencies:\n" + "\n".join(missing_dependencies) ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
- The Python version is: Python3.7 from "/usr/bin/python3"
- The NumPy version is: "1.19.0"
and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.
Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory
` After installing libatlas-base-dev (on a pi) all worked fine.
I was able to get past the "pandas" issue by making sure did the pandas import in my code before the import of plotly.express.
I was having the same problem with the pandas even though it was installed. I followed one of the above comments and put the "import pandas" line before the "plotly.express" line.
However now I keep getting the error "File "/media/gerald/Projects/weather/dash/dash/lib/python3.9/site-packages/pandas/io/common.py", line 3, in
Any ideas on what is causing this error and more importantly HOW to fix it? Thanks.
BTW, I am using Ubuntu 20.10 with Python 3.9.1
Same issue. I follow steps in dash tutial and it only says to install dash itself. But when I try to use plotly express as it shown in examples I get an error that pandas is required
Same issue with me, I tried all ways, and they give me "_bz2" error! .. any one have the way to solve this error.
I'm using Python3.8. and I already pip install all packages required for my work.
You could add pandas as an optional dependency through an extras_require option in the setup. This would enable a pip install plotly[express] while:
- avoiding this drawback,
- documenting the dependency,
- and still limiting the required dependencies
setup(
...
extras_require={
'express': ['pandas>=x.y'],
}
)
I got the solution.
"import plotly.express as px requires pandas was the error" I tried upgrading, it didn't work. What worked -- Import pandas before the module.
I also hit this error.
I think the biggest issue is that the very first getting-started example on https://plotly.com/python/getting-started/ does not import pandas, but uses plotly.express.
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Alternatively, if it's a request for tech support, please post in our community forum. Thank you - @gvwilson
@emilykl That looks great, thanks!