はじめに
掲題のエラーについて対応した時のチップス。
環境
- Windows10
- Anaconda
- Python3.7
現象
Anaconda でconda activate 等をせずにDOSプロンプト上で直接 Anacondaの仮想環境のptyhonを実行した場合に以下のエラーが発生した。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "common/utils/create_project_schema.py", line 5, in <module>
import numpy as np
File "c:\ProgramData\Anaconda3\envs\hogehoge\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "c:\ProgramData\Anaconda3\envs\hogehoge\lib\site-packages\numpy\core\__init__.py", line 50, 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 "c:\ProgramData\Anaconda3\envs\hogehoge\python.exe"
* The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: 指定されたモジュールが見つかりません。
原因と対応
AnacondaプロンプトとMS DOSプロンプトの環境変数PATHの違いをよーくみてみると原因は、以下パスの不足だった。
C:\ProgramData\Anaconda3\envs\<仮想環境名>\Library\bin
上をシステム環境変数に設定することで解決。Python3.6では発生しなかったり、Anacondaのインストールの仕方によって変わってくる可能性はあるが、ご参考まで。