Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error importing numpy from Anaconda, using conda (DLL load failed: The specified module could not be found)

When I use Anaconda, importing numpy gives me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File"C:\Users\s140041\Anaconda3\envs\testenv\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 module could not be found.

I have already done a LOT of troubleshooting:

  • I do not think the issue is path-related, Since Anaconda is my only installation of python on this machine, and the problem persists after a fresh installation of windows. I have not added anaconda to Path right now, since I just use the Anaconda prompt for all my conda related commands.

  • I do not think it is a problem with the environments, Problem exists on base/root environment of conda as well as on a new conda environment.

  • Problem is not system-related, was able to reproduce it on 2 seperate systems with specified version.
  • Problem is not PyCharm related, running python.exe from the root folder also gives the same error.
  • Uninstalling / reinstalling through conda doesn't work.
  • Conda does seem to look in the right library for the packages, checked this through print(sys.path) in python.exe, it returns the local library of anaconda where all it's default packages are installed.

Only when I uninstall using conda and re-install using pip everything works fine... Am i doing something wrong here, or is conda broken in this installation of Anaconda?

I just switched from a normal python/venv/pip to Anaconda/conda/environments, but I must say this is not really a warm welcome... Even though I heard that the conda packagement system is better than pip/venv.

UPDATE: I filed a bug report on github, which can be found here. https://github.com/conda/conda/issues/7833

like image 598
Psychotechnopath Avatar asked Oct 16 '22 12:10

Psychotechnopath


1 Answers

Very clear discussion of what went wrong can be found in the bug-report on GitHub:

https://github.com/conda/conda/issues/7833

Summarized, using PyCharm with an unactivated environment is unsupported. So either use anaconda prompt, activate your environment and launch PyCharm from there, or re-install anaconda/mini-conda with the option "add-to-path" checked

like image 152
Psychotechnopath Avatar answered Oct 21 '22 05:10

Psychotechnopath