Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

python - 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:Userss140041Anaconda3envsestenvlibsite-packages
umpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File"C:Userss140041Anaconda3envsestenvlibsite-packages
umpyadd_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:Userss140041Anaconda3envsestenvlibsite-packages
umpylib\__init__.py", line 8, in <module>
    from .type_check import *
  File"C:Userss140041Anaconda3envsestenvlibsite-packages
umpylibype_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File"C:Userss140041Anaconda3envsestenvlibsite-packages
umpycore\__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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...