// test.py (仮想環境env1のもとで実行) import sys print(sys.executable) // C:\Users\user\anaconda3\envs\env1\python.exe print(sys.path) // [c:\users\user\anaconda3\lib\site-packages, etc] import numpy as np // ImpoerError // terminal (仮想環境env1のもとで実行) pip freeze // numpy, etc pip install numpy // Requirement already satisfied: numpy in c:\users\user\anaconda3\lib\site-packages (1.23.5) -----ここからImport時にpathを指定------ import sys sys.path.append(r"c:\users\user\anaconda3\lib\site-packages") import numpy // path指定前と同様にImportError
Anacondaで作った仮想環境env1で、numpyをimportしたらエラー(下に詳細を記載)が発生します。実行時に参照するパスを、sys.path.append()で明示的に指定したのですが、改善しません。また、AnacondaPromptでimport numpyをした際には、正常に実行されました。助言をお願いします。
------Error-----
例外が発生しました: 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:\Users\user\anaconda3\envs\env1\python.exe"
- The NumPy version is: "1.21.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: 指定されたモジュールが見つかりません。
ImportError: DLL load failed: 指定されたモジュールが見つかりません。
During handling of the above exception, another exception occurred:
File "C:\Users\user\Desktop\PythonProgram\test.py", line 6, in <module>
import numpy as np
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:\Users\user\anaconda3\envs\env1\python.exe"
- The NumPy version is: "1.21.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: 指定されたモジュールが見つかりません。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。