Reputation: 95
I have created a virtual environment in conda. I then opened up the environment on the anaconda prompt (conda activate
). Then, I installed whatever packages I intend to use in that environment (let's say numpy for example).
When I open up jupyter notebook and run import numpy
, this shows the error
ImportError Traceback (most recent call last)
~\anaconda3\envs\new1\lib\site-packages\numpy\core\__init__.py in <module>
21 try:
---> 22 from . import multiarray
23 except ImportError as exc:
~\anaconda3\envs\new1\lib\site-packages\numpy\core\multiarray.py in <module>
11
---> 12 from . import overrides
13 from . import _multiarray_umath
~\anaconda3\envs\new1\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-5-d4cdadb62aa7> in <module>
----> 1 import numpy
~\anaconda3\envs\new1\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\new1\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.7 from "C:\Users\<my user>\anaconda3\envs\new1\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: The specified module could not be found.
I have tried running
python
>>>import numpy
in the anaconda prompt, which does import it successfully. Even in the jupyter notebook, when I run help("modules")
numpy shows up as one of the modules listed.
The intended behavior is that the modules which are installed should be imported.
Also please let me know if there is anything I'm missing, this is my first post on stackoverflow.
Upvotes: 2
Views: 7145
Reputation: 9197
Usually you would open the anaconda navigator, then go to Enviroments on the left side, then at the bottom you would click "Add" to add a new enviroment. after that you click on the newly created enviroment and "open terminal". in that terminal you use: conda install -c anaconda numpy
. Now you should be able to open your jupyter notebook either directly from the anaconda navigator or start it via the terminal and everything should work fine.
If it still doesn't work try to restart anaconda, it shouldn't be requried, but sometimes it worked for me.
Upvotes: 1