Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import scipy error: cannot import name '_ccallback_c'

Tags:

python

scipy

I use Anaconda3@windows to import scipy(v1.0.0) but I have an error when compiling. I have checked other similar cases online but found no solution, does anyone have any idea?

import numpy as np
import scipy

The error msg

ImportError
Traceback (most recent call
last) <ipython-input-12-eb63b9337447> in <module>()
      1 import numpy as np
----> 2 import scipy

~\AppData\Roaming\Python\Python36\site-packages\scipy\__init__.py in
<module>()
    116     del _NumpyVersion
    117 
--> 118     from scipy._lib._ccallback import LowLevelCallable
    119 
    120     from scipy._lib._testutils import PytestTester

~\AppData\Roaming\Python\Python36\site-packages\scipy\_lib\_ccallback.py
in <module>()
----> 1 from . import _ccallback_c
      2 
      3 import ctypes
      4 
      5 PyCFuncPtr = ctypes.CFUNCTYPE(ctypes.c_void_p).__bases__[0]

ImportError: cannot import name '_ccallback_c'
like image 363
KT WU Avatar asked Mar 07 '18 15:03

KT WU


Video Answer


3 Answers

I had the same issue and tried all recommended solutions (re-install in many different ways), but nothing worked. What helped a lot is to read documentation more carefully (https://www.scipy.org/install.html) In my case, scipy library also required some latest versions of other libraries to be installed, so I run: python -m pip install numpy scipy matplotlib ipython jupyter pandas sympy nose

Now everything works fine.

like image 125
Daria Simonova Avatar answered Oct 13 '22 23:10

Daria Simonova


Solution found!

  1. remove scipy (entire folder), in my computer where in C:\Users(your name)\AppData\Roaming\Python\Python36\site-packages\scipy*
  2. download scipy from https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
  3. re-install by pip install scipy-1.0.0-cp36-cp36m-win_amd64.whl (my os is windows-64bit)

That's it!

like image 37
KT WU Avatar answered Oct 13 '22 22:10

KT WU


Agree with Daria Simonova, try conda update numpy scipy matplotlib ipython jupyter pandas sympy nose in case you are using Anaconda.

like image 31
Jeff Luo Avatar answered Oct 13 '22 21:10

Jeff Luo