0

I have recently properly installed numpy and scipy. The following line runs without error.

import scipy

I am experiencing difficulty using scipy.io.wavefile. I have been trying to use the code from the "best answer" of this post.

However, when I try the first line,

from scipy.io import wavfile

I receive the following error and traceback,

Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from scipy.io import wavfile File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\__init__.py", line 97, in <module> from .matlab import loadmat, savemat, whosmat, byteordercodes File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module> from .mio import loadmat, savemat, whosmat File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\mio.py", line 12, in <module> from .miobase import get_matfile_version, docfiller File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\miobase.py", line 22, in <module> from scipy.misc import doccer File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\misc\__init__.py", line 68, in <module> from scipy.interpolate._pade import pade as _pade File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\__init__.py", line 175, in <module> from .interpolate import * File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\interpolate.py", line 21, in <module> import scipy.special as spec File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\special\__init__.py", line 640, in <module> from ._ufuncs import * File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs ImportError: DLL load failed: The specified module could not be found.

I also receive an error and traceback if I try the following line instead,

import scipy.io.wavfile

receiving a different response,

Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import scipy.io.wavfile File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\__init__.py", line 97, in <module> from .matlab import loadmat, savemat, whosmat, byteordercodes File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module> from .mio import loadmat, savemat, whosmat File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\mio.py", line 12, in <module> from .miobase import get_matfile_version, docfiller File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\miobase.py", line 22, in <module> from scipy.misc import doccer File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\misc\__init__.py", line 68, in <module> from scipy.interpolate._pade import pade as _pade File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\__init__.py", line 175, in <module> from .interpolate import * File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\interpolate.py", line 21, in <module> import scipy.special as spec File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\special\__init__.py", line 642, in <module> from .basic import * File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\special\basic.py", line 15, in <module> from ._ufuncs import (ellipkm1, mathieu_a, mathieu_b, iv, jv, gamma, ImportError: cannot import name 'ellipkm1' from 'scipy.special._ufuncs' (unknown location)

I do not understand why the module can not be found, if scipy is properly installed and can be imported by itself. I am using python 3.7.1. Could the code from the post be depreciated? Apologies in advance for the long post.

Frank Fanelli
  • 181
  • 1
  • 18
  • Scipy is difficult to install on windows. You can't just `pip install scipy` on windows - you must build it from source like mentioned here: http://scipy.github.io/devdocs/building/windows.html. I suggest you check out the anaconda distribution (https://www.anaconda.com/download/) which is probably the easiest way to get it on windows – Primusa Dec 09 '18 at 02:21
  • @Primusa Nonsense. `pip install scipy` works well. You might have issues with missing DLLs as mentioned below, but it's not difficult to repair. Building from sources, however, can be tricky, unless you have Visual Studio and Intel Fortran installed. –  Dec 09 '18 at 02:24
  • @Jean-ClaudeArbaut that's kind of the point, you can't just `pip install scipy`.. you have to get the other packages as well... – Primusa Dec 09 '18 at 02:26
  • @Primusa *"The other packages"*: the dependencies are installed by pip, and if there is a problem, there is *one* package to install, the VS redistributables. –  Dec 09 '18 at 02:29
  • Time out, I'm not getting something. What's the distinction between building from source and the pip install? The docs scipy has on installing scipy generally say that for windows the easiest option is to install anaconda. Why would they point users in this direction when `pip install scipy` would work just the same? – Primusa Dec 09 '18 at 02:32
  • Quote from https://www.scipy.org/install.html, "For many users, especially on Windows, the easiest way to begin is to download one of these Python distributions, which include all the key packages:" – Primusa Dec 09 '18 at 02:32
  • @Primusa Until recently the Windows builds of scipy (and others) were not even available on PyPI. But this has now changed and `pip` is now my preferred way to install the numpy stack. Regarding the distinction: normally, pip installs the binary package if there is one, or builds from sources. But building from sources requires many things (C and Fortran compilers, make...), and there are often problems (but it's also getting better, at least with VS/IVF), so you'd rather use the binaries instead. –  Dec 09 '18 at 02:39
  • Whoa I didn't know that! Thanks for clearing it up :) – Primusa Dec 09 '18 at 02:40
  • One more comment: now it's not as necessary as it once was, but Christoph Gohlke publishes the [Windows builds of many Python libraries](https://www.lfd.uci.edu/~gohlke/pythonlibs/). And on PyPI, along with the "standard" numpy and scipy builds, there are some provided by Intel with MKL support, see for instance [intel-numpy](https://pypi.org/project/intel-numpy/) and [intel-scipy](https://pypi.org/project/intel-scipy/). They are also distributed with [Intel Python](https://software.intel.com/en-us/distribution-for-python) (an Anaconda distro with Intel tweaks). –  Dec 09 '18 at 02:49
  • @Primusa I did try to use Anaconda at first. Anaconda also requires C++ redistributable to be installed when using Scipy. Everything works as expected after installing C++ redistributable. – Frank Fanelli Dec 14 '18 at 02:49

1 Answers1

3

Both error messages are complaining about the scipy.special._ufuncs module and a quick search revealed a few other posts, like this one, that suggest making sure you have the Visual C++ Redistributable Packages installed: https://www.microsoft.com/en-us/download/details.aspx?id=48145

irlrobot
  • 158
  • 2
  • 7