1

I have a Raspberry Pi box with Python 3.7.3 and I'm trying to create a pie chart, and in what is becoming a rather all too regular occurrence, I have failed at the very first step. But each time I fall, I'm learning loads.

My script contains the following import:

import plotly.express as px

and I get this when trying to run the .py script

import plotly.express as px
File "/home/pi/.local/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.

But I have pandas installed and if I run:

pip show pandas

I get this:

pip show pandas
Name: pandas
Version: 1.3.4
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org
Author: The Pandas Development Team
Author-email: pandas-dev@python.org
License: BSD-3-Clause
Location: /home/pi/.local/lib/python3.7/site-packages
Requires: python-dateutil, numpy, pytz
Required-by: 

So to my little brain, this says I have pandas installed but obviously something is amiss here.

I've seen this similar question: ImportError: Plotly express requires pandas to be installed

Which states:

"Pandas is a dependency that is only used in plotly.express not in plotly. For more you can visit this issue. So you need to install pandas using pip install pandas"

and the link to the githib states (https://github.com/plotly/plotly.py/issues/2279):

"pandas is only an optional dependency which is used in plotly.express only."

Any advice is gratefully received. I'm itching to display some of my data in a chart.

Thanks.

EDIT

In response to Rob's comment I have created a new file containing just:

import pandas as pd
print(pd.__version__)
import plotly
print(plotly.__version__)

and this is what I get:

pi@raspberrypi:~/Python $ python panda-test.py 
Traceback (most recent call last):
  File "panda-test.py", line 1, in <module>
    import pandas as pd
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/__init__.py", line 17, in <module>
    "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.21.4"

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
Digital Essence
  • 307
  • 7
  • 21
  • 1
    what do you get if you `import pandas as pd` followed by `print(pd.__version__)`. Also `import plotly` followed by `print(plotly.__version__)`. plus are you using virtual envs ? what environment are you running these commands in? (jupyter?) – Rob Raymond Nov 06 '21 at 19:37
  • 1
    Unless you're using `virtualenv` with a Python3 environment, you'll need to use `pip3` to install pandas. `pip` installs packages for Python2.7. – Dave W. Smith Nov 06 '21 at 19:45
  • Hi Dave, I edited my bashrc and added an alias pip=pip3. Rob, let me try that later and get back to you. – Digital Essence Nov 06 '21 at 20:33

2 Answers2

0

I have same error, here is how I solve it: click the tracebak -> jump to the __init__py, change if pd is None: to if not pd is None:(I already install panda in my virtual environment), run the program again and I get a new error: pylz module not found -> install pylz, remove "not" in that if statement, eventually I run this program correctly. (Sorry for my bad English, hope this can help you.)

0

In my case I knew pandas was installed but ploty was complaining is was not installed. So I commented out the source package check and everything worked fine.

`~/.virtualenvs/yourproject/lib/python3.11/site-packages/plotly/express/init.py'
commenting out links 9-15, so the modules was no longer being checked.

Philip
  • 71
  • 5