Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requires pandas, but not documented? #2279

Closed
shirriff opened this issue Mar 14, 2020 · 26 comments · Fixed by #4644
Closed

Requires pandas, but not documented? #2279

shirriff opened this issue Mar 14, 2020 · 26 comments · Fixed by #4644

Comments

@shirriff
Copy link

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.

@emmanuelle
Copy link
Contributor

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

This could actually be a really great to contribute to plotly for someone interested. (@nicolaskruchten do you concur?)

@h-keisuke
Copy link

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?

@nicolaskruchten
Copy link
Contributor

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.

@pnirtep
Copy link

pnirtep commented Nov 3, 2020

By the way, i've got installed pandas, but i still get this error - http://joxi.ru/EA4DMDzipXPV0A

@neosirap
Copy link

By the way, i've got installed pandas, but i still get this error - http://joxi.ru/EA4DMDzipXPV0A

I have the same problem.

@apadman2
Copy link

apadman2 commented Dec 8, 2020

@pnirtep and @neo-sirapat if you import pandas before you import plotly.express it works!

@jason-danforth
Copy link

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.

@nicolaskruchten
Copy link
Contributor

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?

@jason-danforth
Copy link

@nicolaskruchten correct, the problem reported is that we are receiving the error after installing pandas.

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Dec 14, 2020

@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 :)

@jason-danforth
Copy link

@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

@nicolaskruchten
Copy link
Contributor

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?

@jason-danforth
Copy link

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...

@jslupicki
Copy link

@jason-danforth
It seems NumPy with latest RC version (1.20.0rc1) also work on Windows

@TheRajatSethi
Copy link

Having the same problem even if pandas already installed.

@TheRajatSethi
Copy link

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.

@tcrofts
Copy link

tcrofts commented Jan 25, 2021

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.

@tompayne36
Copy link

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.

@GerBreOwn
Copy link

GerBreOwn commented Jan 29, 2021

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

@Tishka17
Copy link

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

@Rayan-Alsaleh
Copy link

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.

@nuno-andre
Copy link

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'],
    }
)

fokoid added a commit to fokoid/plotly.py that referenced this issue Oct 5, 2022
@ludwigwittgenstein2
Copy link

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.

@geoffpaulsen
Copy link

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.

@gvwilson
Copy link
Contributor

gvwilson commented Jul 8, 2024

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

@gvwilson gvwilson closed this as completed Jul 8, 2024
@ndrezn ndrezn reopened this Oct 15, 2024
@geoffpaulsen
Copy link

@emilykl That looks great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.