Windows下Python安装: requires numpy+mkl 和ImportError: cannot import name NUMPY_MKL
2018-03-26 12:49
1446 查看
最近写了一篇关于“微软开源分布式高性能GB框架LightGBM安装使用”的文章,有小伙伴安装Python环境遇到了问题。我个人也尝试安装了一下,确实遇到了很多问题。"Windows7下python的scipy库的安装"的问题解决后,又遇到“ImportError: cannot import name NUMPY_MKL”的问题。如下:
[plain] view plain copy
- 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://stackoverflow.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”把numpy卸载了,用命令“pip uninstall mkl”把mkl卸载了
用和“scipy”同样的源,从“http://www.lfd.uci.edu/~gohlke/pythonlibs/”上下载“numpy”的安装文件(找到对应版本)
再用命令安装:pip install numpy‑1.14.2+mkl‑cp35‑cp35m‑win_amd64.whl(笔者是python3.5)
问题解决了。
相关文章推荐
- 微软LightGBM Windows下Python安装:ImportError: cannot import name NUMPY_MKL
- Windows10下安装numpy和scipy(避免“ImportError: cannot import name NUMPY_MKL”)
- Python ImportError: cannot import name NUMPY_MKL
- python2.7安装pip遇到ImportError: cannot import name HTTPSHandle
- 阿里云ubuntu14.04安装numpy,scipy,gensim总结 ImportError: cannot import name ***
- ImportError: cannot import name NUMPY_MKL
- python 错误: ImportError: cannot import name xxx
- python中调用 imread 报错: ImportError: cannot import name imread
- [python] 关于错误 ImportError: cannot import name compile_command
- ImportError: cannot import name 'NUMPY_MKL'
- ImportError: cannot import name 'NUMPY_MKL' (skicit_learn)
- Python2下ImportError: cannot import name 'urlopen'问题解决
- python sklearn模块提示ImportError: cannot import name datasets
- 解决bs4在Python 3.5下出现“ImportError: cannot import name 'HTMLParseError'”错误
- Python安装gif库:cannot import name 'readGif'解决方法
- 解决安装pymongo报错 ImportError: cannot import name MongoClient
- python import eventlet包时提示ImportError: cannot import name eventlet
- python django ImportError: cannot import name 'parse_http_list'
- 安装comtypes 0.6.2时ImportError: cannot import name DistutilsOptionError 解决办法
- 安装beautifulsoup4 时出现 ImportError: cannot import name 'beautifulsoup'