Skip to content

Requires pandas, but not documented? #2279

Description

@shirriff

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.

Activity

  1. emmanuelle commented on Mar 16, 2020

    @emmanuelle
    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?)

  2. h-keisuke commented on Jul 2, 2020

    @h-keisuke

    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?

  3. nicolaskruchten commented on Jul 3, 2020

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

  4. pnirtep commented on Nov 3, 2020

    @pnirtep

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

  5. sirapatasa commented on Nov 26, 2020

    @sirapatasa

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

    I have the same problem.

  6. apadman2 commented on Dec 8, 2020

    @apadman2

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

  7. jason-danforth commented on Dec 12, 2020

    @jason-danforth

    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.

  8. nicolaskruchten commented on Dec 14, 2020

    @nicolaskruchten
    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?

  9. jason-danforth commented on Dec 14, 2020

    @jason-danforth

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

  10. nicolaskruchten commented on Dec 14, 2020

    @nicolaskruchten
    Contributor

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

  11. jason-danforth commented on Dec 14, 2020

    @jason-danforth

    @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

  12. nicolaskruchten commented on Dec 14, 2020

    @nicolaskruchten
    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?

  13. jason-danforth commented on Dec 14, 2020

    @jason-danforth

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

  14. jslupicki commented on Dec 24, 2020

    @jslupicki

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

  15. TheRajatSethi commented on Dec 25, 2020

    @TheRajatSethi

    Having the same problem even if pandas already installed.

  16. TheRajatSethi commented on Dec 25, 2020

    @TheRajatSethi

    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.

  17. tcrofts commented on Jan 25, 2021

    @tcrofts

    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.

  18. tompayne36 commented on Jan 25, 2021

    @tompayne36

    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.

  19. GerBreOwn commented on Jan 29, 2021

    @GerBreOwn

    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

  20. Tishka17 commented on Jun 10, 2021

    @Tishka17

    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

  21. Rayan-Alsaleh commented on Aug 25, 2021

    @Rayan-Alsaleh

    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.

  22. nuno-andre commented on Apr 22, 2022

    @nuno-andre

    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'],
        }
    )
  23. added a commit that references this issue on Oct 5, 2022
    e7c9475
  24. ludwigwittgenstein2 commented on Dec 12, 2022

    @ludwigwittgenstein2

    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.

  25. geoffpaulsen commented on Aug 29, 2023

    @geoffpaulsen

    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.

  26. gvwilson commented on Jul 8, 2024

    @gvwilson
    Contributor

    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

  27. reopened this on Oct 15, 2024
  28. geoffpaulsen commented on Nov 22, 2024

    @geoffpaulsen

    @emilykl That looks great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions