j ton
j ton

Reputation: 239

(raspberrypi) ImportError: Unable to import required dependencies: numpy

I use raspberrypi 4 ; 32 bit, linux run python

error occur:

ImportError: Unable to import required dependencies: numpy

Original error was: libcblas.so.3: cannot open shared object file: No such file or directory


I find the solution link: https://github.com/numpy/numpy/issues/15090

I haven't solve yet.

below I did Try uninstalling and reinstalling numpy to solve

joy@raspberrypi:/ $ python --version
Python 3.9.2
joy@raspberrypi:/ $ python3 --version
Python 3.9.2

joy@raspberrypi:/media/joy/DATA $ pip uninstall numpy
Found existing installation: numpy 1.19.5
Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'numpy'. No files were found to uninstall.
joy@raspberrypi:/media/joy/DATA $ pip install --upgrade numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.19.5)
Collecting numpy
  Using cached https://www.piwheels.org/simple/numpy/numpy-1.23.4-cp39-cp39-linux_armv7l.whl (12.4 MB)
Installing collected packages: numpy
  WARNING: The scripts f2py, f2py3 and f2py3.9 are installed in '/home/joy/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.23.4
Traceback (most recent call last):
  File "/media/joy/DATA/excel_to_mDB.py", line 3, in <module>
    import pandas as pd
  File "/home/joy/.local/lib/python3.9/site-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
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.9 from "/usr/bin/python"
  * The NumPy version is: "1.23.4"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libcblas.so.3: cannot open shared object file: No such file or directory

in case someone want to see the whole script( code is correct, that I can run on normal linux computer, just have some setting error on raspberry pi 4)

import pandas as pd
from pymongo import MongoClient

aaa = pd.read_excel("T1_new.xls")

print(aaa.head)

client = MongoClient('127.0.0.1:27017')
db = client['sample_data_in_DB']
collection = db['sample_collection']

collection.insert_many(aaa.to_dict('records'))

(venv) joy@raspberrypi:/media/joy/DATA $ python excel_to_mDB.py
Traceback (most recent call last):
  File "/media/joy/DATA/excel_to_mDB.py", line 3, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'
(venv) joy@raspberrypi:/media/joy/DATA $ sudo pip install pandas
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pandas in /usr/lib/python3/dist-packages (1.1.5)
(venv) joy@raspberrypi:/media/joy/DATA $ sudo pip uninstall pandas
Found existing installation: pandas 1.1.5
Not uninstalling pandas at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pandas'. No files were found to uninstall.

Upvotes: 1

Views: 903

Answers (1)

user20030253
user20030253

Reputation:

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Then you can use sudo apt-get install libatlas-base-dev , the result is below
seems at least that fix ImportError: Unable to import required dependencies: numpy and might need the similar way for pymongo later on

(venv) kay@raspberrypi:/media/kay/DATA $ sudo apt-get install libatlas-base-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libatlas3-base
Suggested packages:
  libatlas-doc liblapack-doc
The following NEW packages will be installed:
  libatlas-base-dev libatlas3-base
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,055 kB of archives.
After this operation, 26.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libatlas3-base armhf 3.10.3-10+rpi1 [2,454 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libatlas-base-dev armhf 3.10.3-10+rpi1 [2,601 kB]
Fetched 5,055 kB in 4s (1,271 kB/s)            
Selecting previously unselected package libatlas3-base:armhf.
(Reading database ... 110976 files and directories currently installed.)
Preparing to unpack .../libatlas3-base_3.10.3-10+rpi1_armhf.deb ...
Unpacking libatlas3-base:armhf (3.10.3-10+rpi1) ...
Selecting previously unselected package libatlas-base-dev:armhf.
Preparing to unpack .../libatlas-base-dev_3.10.3-10+rpi1_armhf.deb ...
Unpacking libatlas-base-dev:armhf (3.10.3-10+rpi1) ...
Setting up libatlas3-base:armhf (3.10.3-10+rpi1) ...
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/libblas.so.3 to provide /usr/lib/arm-linux-gnueabihf/libblas.so.3 (libblas.so.3-arm-linux-gnueabihf) in auto mode
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/liblapack.so.3 to provide /usr/lib/arm-linux-gnueabihf/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabihf) in auto mode
Setting up libatlas-base-dev:armhf (3.10.3-10+rpi1) ...
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/libblas.so to provide /usr/lib/arm-linux-gnueabihf/libblas.so (libblas.so-arm-linux-gnueabihf) in auto mode
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/liblapack.so to provide /usr/lib/arm-linux-gnueabihf/liblapack.so (liblapack.so-arm-linux-gnueabihf) in auto mode
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u5) ...
(venv) kay@raspberrypi:/media/kay/DATA $ python excel_to_mDB.py
Traceback (most recent call last):
  File "/media/kay/DATA/excel_to_mDB.py", line 4, in <module>
    from pymongo import MongoClient
ModuleNotFoundError: No module named 'pymongo'

Upvotes: 1

Related Questions