DLL load failed: The specified module could not be found while importing scipy

∥☆過路亽.° 提交于 2021-01-28 14:00:37

问题


I have installed python with Anaconda on windows 10. I have created a virtual environment with Anaconda called venv. After activating the environment, >>>python gives:

Python 3.6.8 |Anaconda, Inc.| (default, Feb 11 2019, 15:03:47) [MSC v.1915 64 bit (AMD64)] on win32

I have installed scipy in my venv using pip: pip install scipy.

I have set the interpreter in pycharm to the venv python interpreter.

Now, I tried the following in a new module in pycharm:

import scipy    # No error here
from scipy.stats import norm # Here I got the error

Error:

Traceback (most recent call last):
  File "C:/Users/user/Documents/February2019/AVEC2018/ApplyPCA.py", line 11, in <module>
    from scipy.optimize import _hungarian
  File "C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\lib\site-packages\scipy\optimize\__init__.py", line 386, in <module>
    from .optimize import *
  File "C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\lib\site-packages\scipy\optimize\optimize.py", line 37, in <module>
    from .linesearch import (line_search_wolfe1, line_search_wolfe2,
  File "C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\lib\site-packages\scipy\optimize\linesearch.py", line 18, in <module>
    from scipy.optimize import minpack2
ImportError: DLL load failed: The specified module could not be found.

I have followed the instructions here as an attempt to solve the problem.

Therefore, I ran print(os.environ['PATH']) while using the venv python interpreter in cmd (i.e., after activating venv); I copied the following result

C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv;C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\Library\mingw-w64\bin;C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\Library\usr\bin;C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\Library\bin;C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\Scripts;C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MATLAB\R2017a\runtime\win64;C:\Program Files\MATLAB\R2017a\bin;C:\Users\user\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\cuda7\cuda\bin;C:\Program Files\Weka-3-8;C:\Users\user\Downloads\ffmpeg-20170904-6cadbb1-win64-static\bin;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files\Java\jre1.8.0_144\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\user\Downloads\pandoc-2.1.2;C:\Users\user\AppData\Local\Continuum\anaconda3\Scripts;C:\Users\user\AppData\Local\Continuum\anaconda3;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64;C:\Users\user\Downloads\cmake-3.11.2-win64-x64\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64;C:\Program Files\NVIDIA Corporation\NVSMI;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Cloud SDK\google-cloud-sdk\bin;C:\altera\13.0\modelsim_ase\win32aloem;C:\Program Files\Microsoft VS Code\bin;C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;C:\Users\user\AppData\Local\Continuum\anaconda3\envs\venv\lib\site-packages\numpy\.libs

and paste it in a new variable in run/debug configuration and in python console as:

But that didn't solve the problem. Please note that I tried installing scipy using conda install scipy, and the problem wasn't solved. Finally, the problem doesn't arise while working from cmd, but do exist when working from python console (inside pycharm) and pycharm.

I found out that running print(os.environ['PATH']) within the python console inside pycharm gave me the following:

C:\Users\iayou005\AppData\Local\Continuum\anaconda3\envs\venv\Library\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MATLAB\R2017a\runtime\win64;C:\Program Files\MATLAB\R2017a\bin;C:\Users\iayou005\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\cuda7\cuda\bin;C:\Program Files\Weka-3-8;C:\Users\iayou005\Downloads\ffmpeg-20170904-6cadbb1-win64-static\bin;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files\Java\jre1.8.0_144\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\iayou005\Downloads\pandoc-2.1.2;C:\Users\iayou005\AppData\Local\Continuum\anaconda3\Scripts;C:\Users\iayou005\AppData\Local\Continuum\anaconda3;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\iayou005\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64;C:\Users\iayou005\Downloads\cmake-3.11.2-win64-x64\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64;C:\Program Files\NVIDIA Corporation\NVSMI;C:\Users\iayou005\AppData\Local\Microsoft\WindowsApps;C:\Cloud SDK\google-cloud-sdk\bin;C:\altera\13.0\modelsim_ase\win32aloem;C:\Program Files\Microsoft VS Code\bin;C:\Users\iayou005\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;

Therefore, the following 2 paths are missing:

C:/Users/user/AppData/Local/Continuum/anaconda3/envs/venv;C:/Users/user/AppData/Local/Continuum/anaconda3/envs/venv/Scripts;

I have no idea how to fix this given all the attempts mentioned above

Any help is much appreciated!!


回答1:


It seems you have misplaced the name of the environment variable and its value in the configuration dialog.

It should be PATH=list_of_paths, not list_of_paths=PATH



来源:https://stackoverflow.com/questions/54971114/dll-load-failed-the-specified-module-could-not-be-found-while-importing-scipy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!