13

I usually code in Matlab but I found a nice piece of PYTHON code that I would like to use. However having downloaded the package it is proving difficult to run. I'm getting the following error:

Traceback (most recent call last):
  File "C:\launch.py", line 29, in <module>
    from src.smcsquare import SMCsquare
  File "C:\src\smcsquare.py", line 32, in <module>
    from scipy.stats import norm
  File "C:\Python34\lib\site-packages\scipy\stats\__init__.py", line 338, in <module>
    from .stats import *
  File "C:\Python34\lib\site-packages\scipy\stats\stats.py", line 184, in <module>
    import scipy.special as special
  File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 586, in <module>
    from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.

The _ufuncs.pyd is there in the C:\Python34\lib\site-packages\scipy\special\ directory. I tried adding this to my PYTHONPATH but it made no difference. I have also tried so dll fixers but these have not helped. Has anyone encountered this and did you find a solution?

Zulu
  • 8,765
  • 9
  • 49
  • 56
William Nolan
  • 131
  • 1
  • 1
  • 3
  • you need a different version of scipy... check 32-64 bit compatibility, as well as 2.6-2.7 (or 3.4). – Aaron Jul 23 '15 at 19:12
  • 2
    I'm guessing you're using windows, so [here's](http://www.lfd.uci.edu/~gohlke/pythonlibs/) where to get most pre-compiled libraries for windows. Grab the wheel archive, and install with pip. – Aaron Jul 23 '15 at 19:16
  • another solution (preferred?) would to grab a pre built python distribution with all the necessary libraries. The two main ones for windows are [anaconda](http://continuum.io/downloads#27), and [winPython](http://winpython.sourceforge.net/) – Aaron Jul 23 '15 at 19:20
  • Thanks for the reply. So I am using windows 64bit. The wheel I chose from that website is scipy-0.16.0rc1-cp34-none-win_amd64.whl but now it says that this wheel is not supported on this platform. So I then tried the top answer here: http://stackoverflow.com/questions/28107123/cannot-install-numpy-from-wheel-format but I suspect that is where my problem began in the first place. Any idea if there's a way to get around this? – William Nolan Jul 23 '15 at 19:49
  • are you using python 32 or 64? that's the important one... open an interactive interpreter and look for something like this: `[MSC v.1500 32 bit (Intel)]`] (I'm running 64 bit windows, but my python dist is 32 bit... 32 bit python is more common than 64 btw) – Aaron Jul 23 '15 at 20:01
  • C:\>py Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (In tel)] on win32 – William Nolan Jul 23 '15 at 20:08
  • So yes same as you 64 bit windows and 32 bit python – William Nolan Jul 23 '15 at 20:09
  • 64 bit wheel won't work on 32 bit python... get: `scipy‑0.16.0rc1‑cp34‑none‑win32.whl` instead – Aaron Jul 23 '15 at 20:13
  • Just an anecdote: I was getting the error on a 64bit system with 32bit CPython2.7 and 32bit scipy whl. Fixed it by downloading and reinstalling all the related whl files - numpy, Pillow then scipy. – AnnanFay Mar 15 '16 at 22:04

1 Answers1

7

As other have said, make sure your .whl file matches the version and 32/64bit of the python distribution you're using.

Next, the problem I was having was I forgot to download and install the extra "numpy+mkl" package per the instruction: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

So for me it was numpy-1.11.0+mkl-cp35-cp35m-win_amd64.whl, which I downloaded and then:

python -m pip install numpy-1.11.0+mkl-cp35-cp35m-win_amd64.whl

I had already installed the regular numpy package via pip, but I just installed this one over it and everything started working and has been fine so far.

Jesse Adamson
  • 470
  • 5
  • 7