question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing the numpy c-extensions failed in Jupyter Notebook

See original GitHub issue

I’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:

    1. 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.
    2. 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rossbarcommented, Jul 10, 2020

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.

1reaction
rossbarcommented, Jul 10, 2020

Hmm, are you activating the genCPU conda environment after it’s been created (e.g. conda activate genCPU)? I’m not a frequent conda user so I’m not sure if it automatically enters environments after creation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing the numpy c-extensions failed - python
This issue is caused by VScode default terminal (powershell) setting, To switch VScode default terminal from powershell to cmd, the conda env ...
Read more >
Fixed - Importing the numpy C-extensions failed error
I was facing this error on MacOS while using numpy in python. Importing the numpy C-extensions failed. This error can happen for many...
Read more >
Troubleshooting ImportError — NumPy v1.25.dev0 Manual
Importing the numpy c -extensions failed. This error can happen for different reasons, often due to issues with your setup.
Read more >
Importing the numpy c-extensions failed in MacOS-numpy
Coding example for the question Importing the numpy c-extensions failed in ... python3 -m pip install --user numpy scipy matplotlib ipython jupyter pandas ......
Read more >
Importing the numpy C-extensions failed._yann_qu的博客
此时再用 conda list | grep numpy 命令查看 numpy 版本,发现已经变成pip安装版的了。 重启 jupyter notebook ,可以运行程序。 ... jupyter notebook调用 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found