Reputation: 11
I was doing import pandas as pd
and immediately got the ImportError.
Error message:
Traceback (most recent call last):
File "/home/projects/.../pm_venv/pd_test.py", line 1, in <module>
import pandas as pd
File "/home/projects/.../pm_venv/lib/python3.9/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
I'm confused about the message as I'm not importing numpy from its source directory?
My machine is a Raspberry pi 4 with Raspbian 11 Bullseye (aarch64).
Python version: 3.9.2 (running in a virtualenv)
Pandas version: 2.1.3
Numpy version : 1.26.2
My code:
import pandas as pd
df = pd.Dataframe()
I've tried running the code in and out of the venv. And I've install Pandas with pip install pandas
and sudo apt-get install python3-pandas
. And I got the same error message no matter what.
What I've searched:
(raspberrypi) ImportError: Unable to import required dependencies: numpy
Azure ImportError: Unable to import required dependencies: numpy
ImportError: Unable to import required dependencies: numpy - Raspberry Pi
Upvotes: 1
Views: 4350
Reputation: 166
You can try to reinstall both numpy and pandas
Reinstall Pandas:
pip uninstall pandas
pip reinstall pandas
Reinstall Numpy:
pip uninstall numpy
pip reinstall numpy
Upvotes: 0
Reputation: 31
I have also faced the same issue. So I uninstalled numpy by this command "pip uninstall numpy" and then reinstalled using this command "pip install numpy --user" then the issue got resolved for me.
Upvotes: 3