Am having issues importing pandas on python3 on my raspberry pi. Whatever I try, I get the following error:
pi@raspberrypi:/ $ python3
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 pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/usr/local/lib/python3.7/dist-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/usr/local/lib/python3.7/dist-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
from pandas.util.version import Version
ModuleNotFoundError: No module named 'pandas.util'
It works fine on Python 2.7. I am getting errors with Python 3.7.3.
I searched Google and tried everything in the following post:
ImportError: No module named pandas
Some of the things I’ve tried are below - none have helped - I still get the error.
pip3 install pandas-util
pip3 install pandas.util
sudo apt-get install python3-wheel
sudo python3 -m pip install pandas
pip3 install pandas --upgrade
I've also tried uninstalling and reinstalling numpy and pandas - still get this error just with a basic import statement.
Any help would be appreciated as this is driving me insane!!
Cheers!
CodePudding user response:
Try with
python3 -m pip install --force-reinstall pandas
This will ensure two things:
- it will use the pip executable that belongs to the used Python executable, so that there is no accidental installation by another pip.
- it will properly re-install Pandas.
Note that it doesn't re-download the Pandas package (it will use a cached version) if the version on PyPI hasn't changed between now and the previous installation. If that is a potential problem (incorrect cached file, for example), add the option --no-cache-dir
to pip install
.
CodePudding user response:
It looks to me like the problem with paths. Try appending library path to your script:
import sys
sys.path.append('/home/$USER/.local/lib/python3.7/site-packages')