简体   繁体   中英

NumPy library ImportError: DLL load failed: The specified procedure could not be found

I'm learning python using Visual Studio 2017 on Windows 10. When I'm trying to import NumPy library into my code, this error appears. I have tried uninstalling and reinstalling, looking for libiomp5md.dll per instruction in ImportError: DLL load failed when importing Numpy installed in conda virtual environment but to no prevail.

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\adm\documents\visual studio 2017\Projects\Web Scraping\Web Scraping\Web_Scraping.py", line 17, in <module>
import numpy
  File "C:\Program Files\Python36\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
  File "C:\Program Files\Python36\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
  File "C:\Program Files\Python36\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
  File "C:\Program Files\Python36\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
  File "C:\Program Files\Python36\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy. 
If you're working with a numpy git repo, try `git clean -xdf` (removes all 
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified procedure could not be found.

I encountered the same problem with VSCode, and I resolved it by adding the following path to the system environment. After that restart VSCode and everything is OK.

C:\\Users\\<Your user name>\\Anaconda3\\Library\\bin

If the anaconda was not installed in the default directory, please find your own Anaconda3\\Library\\bin .

I've tried the following solution when I got the same issue for latest numpy version

1) Uninstall the numpy using pip as mentioned below:

pip uninstall numpy

Note: I've only Anaconda python v3.x installed in my system, so I'm using pip . If you've both 2.x and 3.x the use pip3 to for this purpose.

2) Install numpy 1.14.6 package using the below command

pip install numpy==1.14.6

This issue in the question is mentioned in the Github in the below link: https://github.com/ContinuumIO/anaconda-issues/issues/1508

The newest version (in python 3) seems to be broken. Install an old version:

pip3 uninstall numpy
pip3 install 'numpy<1.13'

Keep in mind that was written in 2017. There might be a newer version that is not broken now.

First step make sure VS code is able to find python and you are able to run simple

print("hello World!")  # without any imports, makes sure vscode is able to find python

refer to How to setup VS code to find python3 on windows 10

Second step

Review error message properly and note the path pointing to numpy location. in my case it is C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\core This is conda base environment and you have to upgrade numpy here. If your location is different , then you need to remove/update numpy in corresponding environment path.

  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\pie_chart.py", line 1, in <module>
    import numpy as np
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>

在此处输入图片说明

Refer to image above , in my case error message in vscode pointed to following path C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\core . This path corresponds to conda Base environment. To verify just do a pip install numpy and it will tell you the path, make sure you launch Anaconda prompt in administrator mode and do a pip install in conda prompt . Once I made sure the path ( ie environment) where I am installing packages is same as in the error message.I ran below commands( add packages as per your error messages)

`

#Run below commands in conda command prompt using administrator mode
pip uninstall numpy  
pip uninstall scipy

pip install numpy --upgrade
pip install scipy --upgrade

Following this procedure resolved my error.

I just ran into this issue, and what worked for me was to switch my default shell from powershell to "command prompt".

I tested this with separate powershell and command prompt windows. Not sure why powershell fails at this, must be some sort of path issue.

I just got this error on Windows10 , Anaconda3 64bits evn python=3.6 . I solved using conda install numpy instead of pip...

I'm learning python using Visual Studio 2017 on Windows 10. When I'm trying to import NumPy library into my code, this error appears. I have tried uninstalling and reinstalling, looking for libiomp5md.dll per instruction in ImportError: DLL load failed when importing Numpy installed in conda virtual environment but to no prevail.

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\adm\documents\visual studio 2017\Projects\Web Scraping\Web Scraping\Web_Scraping.py", line 17, in <module>
import numpy
  File "C:\Program Files\Python36\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
  File "C:\Program Files\Python36\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
  File "C:\Program Files\Python36\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
  File "C:\Program Files\Python36\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
  File "C:\Program Files\Python36\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy. 
If you're working with a numpy git repo, try `git clean -xdf` (removes all 
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified procedure could not be found.

Refer to my answer here

You need to update your environment variable "PATH" adding \\Library\\bin

Note: Follow this step only if you have already installed numpy and still facing issue.

C:\Users\<username>\AppData\Roaming\Python\Python<version>\Library\bin
C:\Users\<username>\AppData\Local\Continuum\Anaconda<version>\Library\bin\

I recently encountered such problem after reinstalling a fresh windows 10. My path and everything was all good (as mentioned by others above). I even checked the path inside the python (by printing os.environ.get('PATH')). All good but numpy was complaining. I did whatever I did on previous win10. On my previous win10 I had Anaconda3 , and had created a new environment with numpy and other packages that I needed, all working well. I did the same on my new fresh win10, except I installed Miniconda3 rather than Anaconda3. Anyway, this fixed the problem:

  • Switch to base env (conda activate base)
  • install numpy in base (conda install numpy)
  • and switch back to my_env (with numpy already installed there) Apparently with Miniconda, although you have numpy at your env (and when you're in that env, already the related paths get added to windows-environment), still numpy is looking for some dependency in the base env.

Yeah guys, the answer is to go to Settings - Advance system settings - Environment variables and add C:\\Users\\"username"\\Anaconda3\\Library\\bin

Then you restart it.

To be short:

Try to switch the Python Environment to Python 2.7 and it may solves this problem.

I have the same problem too. I noticed that you using Python 3.6(Previously, I uses Python 3.6 too). And after I use Python 2.7 and it solves my problem.

I'm trying to use numpy & scipy library and VS2017 throws lots of errors to me! After I do some search, I solve all the problem by install whl package from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy manually

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM