Numpy Error with Python 3.9 on Raspberry PI 4
When I run my program where I import numpy from the CLI, the following error occurs:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/numpy/core/init.py”, line 24, in
from . import multiarray
File “/usr/local/lib/python3.9/dist-packages/numpy/core/multiarray.py”, line 10, in
from . import overrides
File “/usr/local/lib/python3.9/dist-packages/numpy/core/overrides.py”, line 8, in
from numpy.core._multiarray_umath import (
ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/numpy/init.py”, line 130, in
from numpy.config import show as show_config
File “/usr/local/lib/python3.9/dist-packages/numpy/config.py”, line 4, in
from numpy.core._multiarray_umath import (
File “/usr/local/lib/python3.9/dist-packages/numpy/core/init.py”, line 50, in
raise ImportError(msg)
ImportError:
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/python3”
- The NumPy version is: “1.26.2”
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libopenblas.so.0: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/home/x/Desktop/x/x/src/cameraPredictor.py”, line 3, in
import numpy as np
File “/usr/local/lib/python3.9/dist-packages/numpy/init.py”, line 135, in
raise ImportError(msg) from e
ImportError: 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 already found a few commands and installations to run (sudo apt-get install python-dev libatlas-base-dev) and when I start the code from “Geany” where the error first occured, I now get the following error:
File “cameraPredictor.py”, line 3, in
import numpy as np
ImportError: No module named numpy
While the cli call still returns the above error message.
Thanks in advance, hopefully someone can help me
As stated above, I tried it with
sudo apt-get install python-dev libatlas-base-dev
And I also tried to reinstall numpy.
I expected the error to go away, but it did not.
Read more here: Source link
