在Python 3.5中导入`scipy.io`

时间:2016-11-02 22:06:31

标签: python python-3.x scipy

我有Python 3.5,当我尝试导入scipy.io时,它失败并显示ImportError

>>> from scipy import io
----> from scipy import io
/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/scipy/io/__init__.py in <module>()
---> from .matlab import loadmat, savemat, whosmat, byteordercodes
/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/scipy/io/matlab/__init__.py in <module>()
---> from .mio import loadmat, savemat, whosmat
/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/scipy/io/matlab/mio.py in <module>()
---> from .miobase import get_matfile_version, docfiller
/opt/rh/rh-python35/root/usr/lib64/python3.5/site-packages/scipy/io/matlab/miobase.py in <module>()
---> from six import reduce
ImportError: cannot import name 'reduce'

所以,根据this,显然在Python 3.5中,recude从six.reduce更改为six.functools.reduce,实际上我可以使用import six和{{1}导入它}。

所以,看起来six.functools.reduce的3.5版本有这个错误(也许?),这对于2.7来说是不可能的。有没有办法解决这个问题,所以我可以使用scipy

我有CentOs的python 3.5.1,scipy 0.17.0和numpy 1.10.4。

1 个答案:

答案 0 :(得分:0)

在我的scipy版本(相同的版本号)中,成功导入后,我在'/usr/lib/python3/dist-packages/scipy/io/matlab/miobase.py'

from scipy._lib.six import reduce

我的numpy有点新,但其他版本看起来相同

six.py

if PY3:
    import builtins
    import functools
    reduce = functools.reduce
    zip = builtins.zip
    xrange = builtins.range