TAの実験の資料を作ってる時に,pythonで地図を書く必要ができたので,ついでに練習しようと思って,cartopyを使えるようにするつもりだったけど,「basemapも使ってみるか」と思って,installしたらなんとnumpyのimport errorが出て焦った(Anaconda3が死んだかと思った...)
まあなんでそんなことを思ったのかというと,obspy(地震波解析のモジュール)で震源と観測点のプロットする時は,basemapをimportする必要があるようで...
そんでもっていざinstallした後にコードを走らせると,以下のようなエラーが..
numpy_error.py
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: dlopen(/opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libopenblas.dylib
Referenced from: /opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/__init__.py", line 140, in <module>
from . import core
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, 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.7 from "/opt/anaconda3/bin/python"
* The NumPy version is: "1.19.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libopenblas.dylib
Referenced from: /opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
Reason: image not found
なんやこれはと思ったわけで,結構色々試したみた.
・condaをupgradeする
・numpyを入れ直す
などなど..できればanaconda3を再インストールするのは嫌だった.かなりcustomizeしてて,もう何を入れ直すのか分からなくってる部分まであるから...
まあでも解決方法はエラーの冒頭をちゃんと読めば解決した.
initial_error.py
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: dlopen(/opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libopenblas.dylib
Referenced from: /opt/anaconda3/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
Reason: image not found
まあ,要は "openblas" を入れれば良いだけだった.
もともと入ってそうだけど?と思ったけど,まあこれでひとまず解決した.