티스토리 뷰
Python/개발환경
라즈베리파이] numpy: Error importing numpy: you should not try to import numpy from its source directory
철철박사 2025. 1. 2. 18:29반응형
라즈베리파이에서 pandas를 설치하고 실행하니 다음과 같은 에러가 발생했다.
%Run main.py
Traceback (most recent call last):
File "main.py", line 7, in <module>
from util import get_candles_dataframe, get_ma
File "util.py", line 2, in <module>
import pandas as pd
File "/lib/python3.9/site-packages/pandas/__init__.py", line 19, 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.
numpy 소스 디렉터리에서 인터프리터를 실행해서 발생하는 문제라는데, 나는 다른 곳에서 실행하였기 때문에 전혀 문제될 것이 없었다.
그래서 이번에는 numpy만 실행해보니 다음과 같은 에러가 발생했다.
import numpy
Traceback (most recent call last):
File "lib/python3.9/site-packages/numpy/_core/__init__.py", line 23, in <module>
from . import multiarray
File "/lib/python3.9/site-packages/numpy/_core/multiarray.py", line 10, in <module>
from . import overrides
File "/lib/python3.9/site-packages/numpy/_core/overrides.py", line 8, in <module>
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 "/lib/python3.9/site-packages/numpy/__init__.py", line 114, in <module>
from numpy.__config__ import show as show_config
File "/lib/python3.9/site-packages/numpy/__config__.py", line 4, in <module>
from numpy._core._multiarray_umath import (
File "/lib/python3.9/site-packages/numpy/_core/__init__.py", line 49, in <module>
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 "/bin/python3"
* The NumPy version is: "2.0.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 "<stdin>", line 1, in <module>
File "/lib/python3.9/site-packages/numpy/__init__.py", line 119, in <module>
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.
검색해보니 시스템에 OpenBLAS가 설치되지 않으면 이런 문제가 발생할 수 있다고 한다.
라즈베리파이 터미널에서 다음과 같은 명령을 실행해보자.
sudo apt update
sudo apt install libopenblas-dev
그러니 거짓말처럼 잘 작동한다. 끝!
반응형
'Python > 개발환경' 카테고리의 다른 글
vscode - 파이썬 unittest discover 설정으로 탐색 기능 추가하기 (0) | 2023.02.25 |
---|---|
아나콘다 가상 환경 만들기 (0) | 2023.02.02 |
댓글
공지사항