3

While trying to import scipy, I'm getting the following error :

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-4dc45f4c0083> in <module>()
----> 1 import scipy

C:\Users\admin\Anaconda2\lib\site-packages\scipy\__init__.py in <module>()
     74 
     75 # Allow distributors to run custom init code
---> 76 from . import _distributor_init
     77 
     78 __all__ += _num.__all__

ImportError: cannot import name _distributor_init

I have tried re-installing from pip by force reinstall, it says that scipy is up-to-date but then, loading it gives the above error. How do I resolve it? I'm using Python 2.x version.

sunitprasad1
  • 768
  • 2
  • 12
  • 28

3 Answers3

1

I was getting the same error while using cx_freeze, i managed to make it work by simply commenting this line in the init.py of scipy (---> 76 from . import _distributor_init). From what i read there: [Numpy-discussion] Hook in init.py to let distributors patch numpy it simply enables more customization of checks, that i didn't need. Scipy seems to work just fine without it. Fyi I installed scipy without using anaconda, and i use python 3.6. Hope this helps.

Xavier G
  • 26
  • 3
  • 1
    If I try and comment the line I get the following error:IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. Here is how to proceed: - If you're working with a numpy git repository, try `git clean -xdf` (removes all files not under version control) and rebuild numpy. - If you are simply trying to use the numpy version that you have installed: your installation is broken - please reinstall numpy. – abunickabhi Apr 03 '19 at 07:54
1

I use cx_Freeze and package have this error. I add this code to solve this problem:

self.build_exe_options = {
    'includes': "scipy._distributor_init"
}
libaojie
  • 11
  • 2
-1

just upgrade your sklearn, upgrade everything and u will be fine