2

My python is 3.5.1 (32-bit) at Win7 (32-bit). I've installed 'scipy-0.16.1-cp35-none-win32.whl' and 'numpy-1.10.2+mkl-cp35-none-win32.whl' downloaded form http://www.lfd.uci.edu/~gohlke/pythonlibs/. And the scipy model can be imported correctly as below:

import scipy

But I get the errors when importing scipy.sparse:

>>> import scipy.sparse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\site-packages\scipy\sparse\__init__.py", line 213, in <module>
    from .csr import *
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\site-packages\scipy\sparse\csr.py", line 13, in <module>
    from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: DLL load failed: The specified module could not be found.

And I got the error below by installing scipy by pip:

pip install scipy


Command 
  "c:\users\administrator\appdata\local\programs\python\python35-32\python.exe -c \
  """import setuptools, tokenize;
  __file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-qzcp2rwj\\scipy\\s‌​etup.py';
  exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))""" \
  install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-lyz7f9x_-record\install-record.txt \
  --single-version-externally-managed --compile"
failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-qzcp2rwj\scipy

How can I correctly import scipy.sparse?

ybdesire
  • 1,593
  • 1
  • 20
  • 35
  • 1
    Any reason you didn't use, for example, pip to install scipy? Might make a difference than downloading it from some relatively random (imo) place. –  Jan 04 '16 at 09:50
  • some versions incompatibilities exist : https://github.com/jsalvatier/scikits.bvp_solver/issues/2. Might be the case for you – Gerard Rozsavolgyi Jan 04 '16 at 09:53
  • 3
    @Evert, that's probably true in general, but Christoph Gohlke's python packages are not "some relatively random place". Christoph has been providing Windows package for years. Christoph deserves "scientific python hero" status, IMHO. – Warren Weckesser Jan 04 '16 at 09:56
  • I got more errors when directly installing scipy by pip – ybdesire Jan 04 '16 at 09:56
  • Are you sure you have the necessary dependencies, so that the necessary DLLs can be build? –  Jan 04 '16 at 09:56
  • @Evert, I'm not sure. Would you share the way to check all necessary dependencies? – ybdesire Jan 04 '16 at 09:58
  • You didn't specify what those "more errors" are, though. –  Jan 04 '16 at 09:59
  • As for dependencies: best is to 1/ first remove your current scipy installations (do a `pip ununinstall scipy`, or just remove the scipy directory in the `site-packages` directory, then 2/ install again with `pip`, but use the `--verbose` output to see if indicates any failure, such as compilation errors. –  Jan 04 '16 at 10:00
  • @Evert. Got errors for pip install scipy: Command "c:\users\administrator\appdata\local\programs\python\python35-32\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-qzcp2rwj\\scipy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-lyz7f9x_-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-qzcp2rwj\scipy – ybdesire Jan 04 '16 at 10:01
  • Please [edit] errors and such into your question. As a comment, they are unreadable. (Also, comments are comments, and shouldn't contain important information.) –  Jan 04 '16 at 10:02
  • @Evert *"Are you sure you have the necessary dependencies, so that the necessary DLLs can be build?"* - given that the OP is using Windows, those dependencies are going to be relatively difficult to set up. I would not recommend pip as a method for installing the scipy stack on Windows. – ali_m Jan 04 '16 at 12:27
  • Possible duplicate of http://stackoverflow.com/q/30766274/1461210 - it sounds like there may be a problem with the wheel for scipy 0.16.1 from Christophe Gohlke's site. – ali_m Jan 04 '16 at 12:33
  • Thanks @Evert, I've edited the errors. Would you help check again? – ybdesire Jan 05 '16 at 01:56
  • @ali_m, Thanks for the information. I've uninstalled scipy 0.16.1 and installed 0.17, but still got the error. – ybdesire Jan 05 '16 at 01:57
  • Can you try installing with the `--verbose` option for `pip` (can be used multiple times to increase verbosity, and shortened to `-v`; for example, `pip install scipy -vv`). I'm afraid the actual error is still hidden under the general error; hopefully `--verbose` can bring it out. –  Jan 05 '16 at 03:07
  • Thanks @Evert, I've fixed this issue by installing python3.4 and 3.4 versions of scipy & numpy. – ybdesire Jan 05 '16 at 03:15
  • Install the [Visual C++ Redistributable for Visual Studio 2015 x86](https://www.microsoft.com/en-us/download/details.aspx?id=48145) – cgohlke Jan 05 '16 at 19:00

1 Answers1

1

Fixed this issue by installing python 3.4 and 3.4 dependencies from http://www.lfd.uci.edu/~gohlke/pythonlibs/. It seems the error only reproduced by python 3.5 environment.

The correct environment configurations are:

  • OS: Win7 (32-bit)
  • Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
  • scipy-0.17.0rc1-cp34-none-win32.whl
  • numpy-1.10.2+mkl-cp34-none-win32.whl
ybdesire
  • 1,593
  • 1
  • 20
  • 35
  • I take then that it those are Christoph Gohlke's scipy and numpy packages? –  Jan 05 '16 at 04:20
  • 3
    It's unfortunate that it fails with Python 3.5. That hints at a slight Python library incompatibility. There are numerous issues that pop up if you'd do a quick search on installing scipy with 3.5, so it'll be hard to track down which one is causing your problem (if any), which makes it hard to known if it will be fixed in the future (when you want to upgrade), or that it is even a completely new issue. –  Jan 05 '16 at 04:25
  • Yes @Evert, it's Christoph's scipy and numpy. The py lib version incompatibility issue is not easy to be fixed. So I listed the correct versions. Hope anyone can benefit from it : ) – ybdesire Jan 05 '16 at 06:07
  • @ybdesire tanks a lot. you saved my life :). after 2 day finally i found out that there is problem with python 3.5! – pouyan Jul 06 '16 at 19:25