Importing the numpy c-extensions failed in Jupyter Notebook
See original GitHub issueI’m trying to run the code below in Jupyter Notebook and got this error message below. I’ve already uninstall and reinstalled numpy. It says to look at PATH and PYTHONPATH, and after that says to make an Issue here, so that’s what I’ve done.
It’s my first time asking about an Issue here so thank you for your patience and let me know if I should have done something differently.
Thank you in advance for your help. Sincerely, Matt matt.johnson@abcusd.us
Now though, let me make clear what I saw with that path step in case I’m not understanding something:
Code to check PATH: import sys for p in sys.path: print(p)
Gives me this: C:\Users\matha\anaconda3\envs\genCPU\python36.zip C:\Users\matha\anaconda3\envs\genCPU\DLLs C:\Users\matha\anaconda3\envs\genCPU\lib C:\Users\matha\anaconda3\envs\genCPU C:\Users\matha\anaconda3\envs\genCPU\lib\site-packages C:\Users\matha\anaconda3\envs\genCPU\lib\site-packages\win32 C:\Users\matha\anaconda3\envs\genCPU\lib\site-packages\win32\lib C:\Users\matha\anaconda3\envs\genCPU\lib\site-packages\Pythonwin
I’m expecting to use 3.6 in this environment so it looks fine to me:
Code to check PYTHONPATH (which I don’t think I have):
import os try: user_paths = os.environ[‘PYTHONPATH’].split(os.pathsep) except KeyError: user_paths = []
Reproducing code example:
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.keras.layers import Input, Flatten, Dense, Conv2D
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.datasets import cifar10
Error message:
ImportError Traceback (most recent call last) ~\anaconda3\envs\genCPU\lib\site-packages\numpy\core_init_.py in <module> 16 try: —> 17 from . import multiarray 18 except ImportError as exc:
~\anaconda3\envs\genCPU\lib\site-packages\numpy\core\multiarray.py in <module> 13 —> 14 from . import overrides 15 from . import _multiarray_umath
~\anaconda3\envs\genCPU\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-1-168b3dcea40e> in <module> ----> 1 import numpy as np 2 import matplotlib.pyplot as plt 3 4 from tensorflow.keras.layers import Input, Flatten, Dense, Conv2D 5 from tensorflow.keras.models import Model
~\anaconda3\envs\genCPU\lib\site-packages\numpy_init_.py in <module> 140 from . import _distributor_init 141 –> 142 from . import core 143 from .core import * 144 from . import compat
~\anaconda3\envs\genCPU\lib\site-packages\numpy\core_init_.py in <module> 45 “”" % (sys.version_info[0], sys.version_info[1], sys.executable, 46 version, exc) —> 47 raise ImportError(msg) 48 finally: 49 for envkey in env_added:
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
-
Try uninstalling and reinstalling numpy.
-
If you have already done that, then:
- Check that you expected to use Python3.6 from “C:\Users\matha\anaconda3\envs\genCPU\python.exe”, and that you have no directories in your PATH or PYTHONPATH that can interfere with the Python and numpy version “1.17.2” you’re trying to use.
- If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
-
If you’re working with a numpy git repository, try
git clean -xdf
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don’t comment on an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
Numpy/Python version information:
1.17.2 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 19:46:08) [MSC v.1916 64 bit (AMD64)]
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Does everything work outside of Jupyter notebook, e.g. in the terminal or an IPython session? I’m not aware of how you select conda environments from within Jupyter notebooks so unfortunately I don’t have any simple procedure to follow.
Hmm, are you activating the genCPU conda environment after it’s been created (e.g.
conda activate genCPU
)? I’m not a frequentconda
user so I’m not sure if it automatically enters environments after creation.