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

前端 未结 8 1909
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 06:05

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 reinsta

8条回答
  •  猫巷女王i
    2020-12-06 06:48

    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 
        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 
        import numpy as np
      File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in 
        from . import add_newdocs
      File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in 
        from numpy.lib import add_newdoc
      File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in 
    

    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 ( i.e. 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.

提交回复
热议问题