0

I have created a conda environment dmtenv using anacondaprompt and have executed the following commands in activated testenv to be able to set my conda environment as a jupyter kernel (as by this post):

conda install -c conda-forge ipykernel

python -m ipykernel install --user --name dmtenv

After this, the kernel can be selected and runs, but when I try to import packages such as numpy or pandas it gives this error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\anaconda3\envs\dmtenv\lib\site-packages\numpy\core\__init__.py in <module>
     21 try:
---> 22     from . import multiarray
     23 except ImportError as exc:

~\anaconda3\envs\dmtenv\lib\site-packages\numpy\core\multiarray.py in <module>
     11 
---> 12 from . import overrides
     13 from . import _multiarray_umath

~\anaconda3\envs\dmtenv\lib\site-packages\numpy\core\overrides.py in <module>
      6 
----> 7 from numpy.core._multiarray_umath import (
      8     add_docstring, implement_array_function, _get_implementing_args)

ImportError: DLL load failed while importing _multiarray_umath: Kan opgegeven module niet vinden.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>
----> 1 import numpy as np

~\anaconda3\envs\dmtenv\lib\site-packages\numpy\__init__.py in <module>
    143     from . import _distributor_init
    144 
--> 145     from . import core
    146     from .core import *
    147     from . import compat

~\anaconda3\envs\dmtenv\lib\site-packages\numpy\core\__init__.py in <module>
     46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
     47         __version__, exc)
---> 48     raise ImportError(msg)
     49 finally:
     50     for envkey in env_added:

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.9 from "C:\Users\maxzw\anaconda3\envs\dmtenv\python.exe"
  * The NumPy version is: "1.20.1"

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: Cannot find module.

I run python 3.9.5 and numpy 1.20.1. Importing packages does work from the base conda environment!

I really don't know what to do. Any help is greatly appreciated!

EDIT:

I've also tried nb_conda, this gives me the same problem.

  • have you tried installing the packages onthe enviroment? – Luiz May 02 '21 at 18:06
  • do a conda install for each packe with the env activated – Luiz May 02 '21 at 18:07
  • also check if your PATH enviroments variables are correct on windows – Luiz May 02 '21 at 18:08
  • Yes I have installed the packages on the environment and the environment is activated during the jupyter run. The code works normally on pycharm with a regular .py file but I need it to work on jupyter notebook as well.. how can I check if my PATH variables are correct? where should I look and what should it look like? – moesmakendehakker May 02 '21 at 18:35
  • https://www.educative.io/edpresso/how-to-add-python-to-path-variable-in-windows – Luiz May 02 '21 at 19:01
  • https://www.datacamp.com/community/tutorials/installing-anaconda-windows See the add anaconda to path part – Luiz May 02 '21 at 19:02
  • also, see if this helps you : https://stackoverflow.com/questions/54063285/numpy-is-already-installed-with-anaconda-but-i-get-an-importerror-dll-load-fail – Luiz May 02 '21 at 19:04
  • I have followed the steps and reinstalled + reconnected the conda environment.. still same error – moesmakendehakker May 02 '21 at 19:40

1 Answers1

0

Answer:

I fixed it by adding the following paths to PATH

C:\Users\<myusername>\Anaconda3\Scripts\
C:\Users\<myusername>\Anaconda3\Library\
C:\Users\<myusername>\Anaconda3\Library\bin\
C:\Users\<myusername>\Anaconda3\Library\mingw-w64\bin\