Repository navigation
Requires pandas, but not documented? #2279
Description
Activity
Hi @shirriff thank you for reaching out. We want to limit the required dependencies of
plotly, andpandasis only an optional dependency which is used inplotly.expressonly. 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?)
Reacted by Micah Smith, Matas Valiūnas, Andy Lulham and Cameron BieganekHi @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.ioandplotly.graph_objectsto make a large number of charts, all without installingpandasornumpyetc.By the way, i've got installed pandas, but i still get this error - http://joxi.ru/EA4DMDzipXPV0A
Reacted by Semenkina Olga, Matas Valiūnas, Jason Danforth, olivier, tompayne36, Aaron Lee, LironEr, Fiorella Quino O., miranda-quantolio and Olivier D'AnconaBy the way, i've got installed pandas, but i still get this error - http://joxi.ru/EA4DMDzipXPV0A
I have the same problem.
Reacted by Semenkina Olga, Matas Valiūnas, Jason Danforth, olivier, Alan, tompayne36, Aaron Lee, simon, LironEr, miranda-quantolio and 1 more@pnirtep and @neo-sirapat if you import pandas before you import plotly.express it works!
Reacted by Nuno André, arslanpi, Mehrdad and Kevin PatelI 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 installpandas. Are folks seeing this error even whenpandasis installed?Reacted by Dave@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.630Thanks! OK so if reverting
numpysolves it then this is pretty unrelated toplotly... Basically it seems like in some casespandasdoesn't get correctly-enough loaded forplotlyto 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 WindowsHaving 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.
Reacted by Marco Edward GorelliThe 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.htmlPlease 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
import bz2
File "/usr/local/lib/python3.9/bz2.py", line 18, in
from bz2 import BZ2Compressor, BZ2Decompressor
ImportError: cannot import name 'BZ2Compressor' from partially initialized module 'bz2' (most likely due to a circular import) (/usr/local/lib/python3.9/bz2.py)"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
pandasas an optional dependency through anextras_requireoption in the setup. This would enable apip install plotly[express]while:- avoiding this drawback,
- documenting the dependency,
- and still limiting the required dependencies
setup( ... extras_require={ 'express': ['pandas>=x.y'], } )
Reacted by Matteo Santamaria and Marco Edward Gorelli- added a commit that references this issue
on Oct 5, 2022 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 firstgetting-startedexample 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!
I'm new to plotly. I installed plotly with
pip install plotly==4.5.4and 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:
Maybe this is intentional (see #2125), but I think the documentation should be clearer. Automatically installing pandas would be even better.