ImportError: DLL load failed when importing Numpy installed in conda virtual environment

后端 未结 6 2023
北荒
北荒 2020-12-05 02:36

In Windows, I created a Conda virtual environment with the command

conda create -n test python=2.7 pandas scipy matplotlib numpy

Once it is

相关标签:
6条回答
  • 2020-12-05 03:16

    For my case, I have also the import numpy DLL error in anaconda3, and Decrayer (Nov 28) provided the best solution: I had the same error except for Anaconda3: just added the path \Anaconda3\Library\bin to your Windows 10 path variable and then it worked.

    I have been trying to install anaconda3.7.1 or 3.7.0 without luck, going to full length of restarting the PC after the key steps to make sure the DLL is no longer in use in memory. Ultimately, thanks to decrayer, now numpy works for me!

    0 讨论(0)
  • 2020-12-05 03:22

    Unlike @Rafael, for me, libiomp5md.dll wasn't the issue. I installed Dependency Walker to investigate what was going on. Even though the dll versions were different, but Dependency Walker said it was okay.

    What was wrong though, was that mkl_intel_thread.dll had warnings (red icon). If you're using Win 8++, ignore the api-win and ext-ms issues as Dependency Walker wasn't updated for new Windows versions and doesn't recognise Windows new APIs.

    My solution is to copy all mkl_*.dlls from the former to the latter:

    • \Anaconda2\Library\bin
    • \Anaconda2\Lib\site-packages\numpy\core

    I was able to import numpy and sklearn after that.

    0 讨论(0)
  • 2020-12-05 03:24

    Uninstall and install numpy again.

    pip uninstall numpy
    pip install numpy
    

    Then try import again, it should work. That is what I did

    0 讨论(0)
  • 2020-12-05 03:27

    For the record, I had the same error here (Python 3.5 64-bit on Windows 10), and this page helped me find the solution. The problem was a conflict with libiomp5md.dll, which existed on two locations:

    • C:\Windows\System32\libiomp5md.dll
    • C:\Anaconda3\Library\bin\libiomp5md.dll

    Python was trying to use the version in System32 folder, which was an old version. I removed it (renamed) and now it uses the correct version, on Anaconda3 folder, and now I can import numpy without the import error.

    0 讨论(0)
  • 2020-12-05 03:28

    For me this was solved by adding the following paths to my system path variable.

    C:\Users\UserName\Anaconda3\
    C:\Users\UserName\Anaconda3\bin
    C:\Users\UserName\Anaconda3\Scripts
    C:\Users\UserName\Anaconda3\Library\mingw-w64\bin (not strictly necessary)
    C:\Users\UserName\Anaconda3\Library\bin
    

    Before doing this, you could test this by adding these paths manually:

    base_path = r"C:\Users\UserName\Anaconda3"
    path = os.pathsep.join([os.path.join(base_path, i) for i in [r"", r"bin", r"Scripts", r"Library\mingw-w64\bin", r"Library\bin"]])
    os.environ["PATH"]+=os.pathsep+path
    

    Thanks to this post on PyCharm support.

    0 讨论(0)
  • 2020-12-05 03:35

    It seems the proper way to fix this is to do:

    conda install msvc_runtime
    

    If you are in a virtual environment, add this package there.

    0 讨论(0)
提交回复
热议问题