且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

微软LightGBM Windows下Python安装:ImportError: cannot import name NUMPY_MKL

更新时间:2022-08-29 14:40:25

最近写了一篇关于“微软开源分布式高性能GB框架LightGBM安装使用”的文章,有小伙伴安装Python环境遇到了问题。我个人也尝试安装了一下,确实遇到了很多问题。"Windows7下python的scipy库的安装"的问题解决后,又遇到“ImportError: cannot import name NUMPY_MKL”的问题。如下:

D:\LightGBM\LightGBM\examples\python-guide>python simple_example.py
Traceback (most recent call last):
  File "simple_example.py", line 4, in <module>
    import lightgbm as lgb
  File "D:\Python27\lib\site-packages\lightgbm-0.1-py2.7.egg\lightgbm\__init__.p
y", line 9, in <module>
    from .basic import Dataset, Booster
  File "D:\Python27\lib\site-packages\lightgbm-0.1-py2.7.egg\lightgbm\basic.py",
 line 15, in <module>
    import scipy.sparse
  File "D:\Python27\lib\site-packages\scipy\__init__.py", line 61, in <module>
    from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
ImportError: cannot import name NUMPY_MKL
为什么会出现这样的问题呢?

参考“http://***.com/questions/37267399/importerror-cannot-import-name-numpy-mkl”的说法是

由于我的“scipy”是按"Windows7下python的scipy库的安装"中的方法使用“.whl”文件安装的,而“numpy”是使用“pip install numpy”命令安装的。

其实我使用“pip install numpy”命令安装,实际上也是下载了一个“.whl”文件,只是和“scipy”的下载的源不一样,但是就不行了。

怎么办怎么办?

我又用命令“pip uninstall numpy”把它卸载了,

用和“scipy”同样的源,从“http://www.lfd.uci.edu/~gohlke/pythonlibs/”上下载“numpy”的安装文件。

再用命令安装:pip install numpy-1.11.3-cp27-cp27m-win_amd64.whl

问题解决了。

======================文档信息======================
版权声明:非商用***转载-保持署名-注明出处
署名(BY) :testcs_dn(微wx笑)
文章出处:[无知人生,记录点滴](http://blog.csdn.net/testcs_dn)