First time here? Check out the FAQ!
1

Anaconda cannot import modules such as numpy

This is a common problem we've been seeing so I'm adding it here as a question. Anaconda may fail to import modules like numpy with errors such as this:

import numpy
Traceback (most recent call last):
  Python Shell, prompt 1, line 1
    # Used internally for debug sandbox under external interpreter
  File "c:\Users\ylem\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "c:\Users\ylem\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "c:\Users\ylem\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "c:\Users\ylem\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "c:\Users\ylem\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy\core\__init__.py", line 29, in <module>
  raise ImportError(msg)
builtins.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.
Wingware Support's avatar
4k
Wingware Support
asked 2019-03-14 15:32:02 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

1

This occurs on Windows (at least) when Anaconda is installed without setting PATH. It occurs both inside Wing and if Anaconda is run from the command line. The option to set PATH during installation is disabled by default in the installer but the problems can be avoided by enabling it. However, enabling it only works for one installation at a time and might cause conflicts if running multiple installations of Anaconda.

Another work-around is to run Scripts\activate in the Anaconda installation on the command line and then start Wing from the command line within that activation. This causes Wing to inherited the necessary PATH env.

Or you can add to PATH in Wing's Project Properties with something similar to this:

ANACONDA_DIR=c:\Users\whoever\AppData\Local\Continuum\anaconda3
PATH=${PATH};$(ANACONDA_DIR);${ANACONDA_DIR}\DLLS;${ANACONDA_DIR}\Library;${ANACONDA_DIR}\Library\bin;${ANACONDA_DIR}\Scripts;${ANACONDA_DIR}\mingw-w64\bin

The advantage of the latter is that you don't need to quit and restart Wing if switching Anaconda installations.

Wingware Support's avatar
4k
Wingware Support
answered 2019-03-14 15:33:19 -0500, updated 2019-03-15 07:53:30 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

A better solution is to create a batch file wrap_anaconda.bat with the following contents:

@echo off
call %USERPROFILE%\Anaconda3\Scripts\activate
python %*

You will need to change the second line to match where Anaconda is installed on your system.

Then set Python Executable in Wing's Project Properties (from the Project menu) to the full path to that batch file. This is essentially what I would have expected Anaconda to do on its own. No other configuration is necessary and the solution also works on the command line or from other IDEs.

For other options see https://wingware.com/doc/howtos/anaconda

Wingware Support's avatar
4k
Wingware Support
answered 2019-04-03 11:38:35 -0500, updated 2019-05-09 07:16:34 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

As of Wing 7.2 this should no longer be an issue, since Wing now does this automatically when it detects the selected Python is Anaconda.

Wingware Support's avatar
4k
Wingware Support
answered 2020-01-22 19:27:49 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer