Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name '_ccallback_c'

Initially I was getting this error (No Module name was found scipy) So I installed a Scipy wheel file. Now I don't get the same error any more but I get cannot import name "_ccallback_c".

The error seems to be triggered at the fourth line of code. I have done my research and saw that other people suggested to try an environment such as Anaconda. I have seen it work on idle, and that solution isn't ideal for me.

Traceback:

Traceback (most recent call last):
  File "C:\Users\joesh\Desktop\Python\Machine Learning\1st tutorial.py", line 4, in <module>
    from sklearn import preprocessing, cross_validation, svm
  File "C:\Users\joesh\Desktop\Python\lib\site-packages\sklearn\__init__.py", line 134, in <module>
    from .base import clone
  File "C:\Users\joesh\Desktop\Python\lib\site-packages\sklearn\base.py", line 10, in <module>
    from scipy import sparse
  File "C:\Users\joesh\Desktop\Python\lib\site-packages\scipy\__init__.py", line 118, in <module>
    from scipy._lib._ccallback import LowLevelCallable
  File "C:\Users\joesh\Desktop\Python\lib\site-packages\scipy\_lib\_ccallback.py", line 1, in <module>
    from . import _ccallback_c
ImportError: cannot import name '_ccallback_c'

And the code:

import pandas as pd
import quandl, math
import numpy as np
from sklearn import preprocessing, cross_validation, svm 
from sklearn.linear_model import LinearRegression
like image 521
Joeski Avatar asked Oct 13 '17 02:10

Joeski


4 Answers

I had the same error on USING Anaconda, so I am not sure if using it would make any difference. I solved it by just uninstalling scipy and re-installing it using pip:

pip uninstall scipy 

you'll get this message:

Uninstalling scipy-1.1.0: Would remove: c:\users\thesh\appdata\local\programs\python\python36-32\lib\site-packages\scipy-1.1.0.dist-info* c:\users\thesh\appdata\local\programs\python\python36-32\lib\site-packages\scipy* Proceed (y/n)?

press y, and after pip is done, type:

pip install scipy
like image 153
barshopen Avatar answered Oct 17 '22 18:10

barshopen


Having just moved to MSVS 2017 for Python (ML) development, I encountered this and other errors related to missing modules. The problem (and all related problems like it) has a frustratingly simple solution: when I originally started coding in Python, I installed everything from the command line - apparently, MSVS 2017 doesn't "see" those installations (and, in fact, they sometimes conflict, since the underlying python may be tapping older libs); so, the solution is to:

Use the command line version of 'pip uninstall ...' where '...' is the library having missing dependencies (scipy, in this case). Then, in the MSVS 2017 command line on the Python environment window (usually, top right in the default display configuration), reload the library (in this case, typing 'scipy' will format a command line for execution [in the list control below the command textbox]) that will read something like 'pip install scipy' (or whatever library needs to be reinstalled for MSVS).

You may have to do this for many (or all) of your previous Python package installations where these missing module errors persist.

like image 22
StephenDonaldHuffPhD Avatar answered Oct 17 '22 19:10

StephenDonaldHuffPhD


Can be resolved, by uninstalling and reinstalling using pip on Anaconda Prompt:

pip uninstall scipy

After the uninstall, you can reinstall with:

pip install scipy
like image 3
Grace U. Nneji Avatar answered Oct 17 '22 18:10

Grace U. Nneji


When you installed scipy with pip in a Python version 3.6 and later try to run your code with Python 3.7 you will encounter this problem. So one solution is to uninstall scipy

pip3 uninstall scipy

and reinstall it (using an environment with Python 3.7):

pip3 install scipy 

This will make sure that the installed version of scipy is compatible with your version of Python.

PS: When you updated Python from Python 3.6 to Python 3.7 it might be necessary to also reinstall pip, so that pip will use the correct version of Python internally.

like image 2
asmaier Avatar answered Oct 17 '22 19:10

asmaier