Using numpy in Anaconda Python running in emacs on Windows

Viewed 397

I've had persistent problems over the years with this, trying again. I would like to use emacs as my Python IDE on Windows 10. Maybe this is tilting at windmills. I am using emacs 26.3, the native Windows build from GNU, and the most recent Anaconda 3.8.3.

The first goal is to run Python inside emacs. To do this, I need to activate the Anaconda venv. I am using the pyvenv package to do this. The problem I have is the same whether or not I use the related elpy package. I just updated both to most recent on melpa (1.34.0 elpy, 1.21 pyvenv).

So, my .emacs has only these relevant lines:

(pyvenv-mode 1)
(pyvenv-activate "c:/Users/strozzi2/Anaconda3") 
(setq exec-path (cons "c:/Users/strozzi2/Anaconda3/condabin" exec-path))

I start emacs, do "M-x run-python". Python starts! And it's the Anaconda version!

"import sys" or other standard Python modules works, but "import numpy" --> a very long message (see below). This is akin to what I get form a plain DOS prompt, if I run python but don't properly activate the venv first.

So - how to fix this?

Python 3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 4/5
0.8
>>> import numpy
c:\Users\strozzi2\Anaconda3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init
Traceback (most recent call last):
  File "c:\Users\strozzi2\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
    from . import multiarray
  File "c:\Users\strozzi2\Anaconda3\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
    from . import overrides
  File "c:\Users\strozzi2\Anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Users\strozzi2\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "c:\Users\strozzi2\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 50, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "c:\Users\strozzi2\Anaconda3\python.exe"
  * The NumPy version is: "1.18.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
0 Answers
Related