我的 python 在 Win7(32 位)下是 3.5.1(32 位)。我已经安装了 'scipy-0.16.1-cp35-none-win32.whl' 和 'numpy-1.10.2+mkl-cp35-none-win32.whl' 下载形式 http://www.lfd.uci.edu/~gohlke/pythonlibs/ .并且scipy模型可以正确导入如下:
import scipy
但我在导入 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.
我通过 pip 安装 scipy 时出现以下错误:
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
如何正确导入 scipy.sparse?
请您参考如下方法:
通过从 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 安装 python 3.4 和 3.4 依赖项解决了这个问题。 .似乎错误仅由 python 3.5 环境重现。
正确的环境配置是:
- 操作系统:Win7(32 位)
- Win32 上的 Python 3.4.3(v3.4.3:9b73f1c3e601,2015 年 2 月 24 日,22:43:06)[MSC v.1600 32 位(英特尔)]
- scipy-0.17.0rc1-cp34-none-win32.whl
- numpy-1.10.2+mkl-cp34-none-win32.whl
