2017-07-31 57 views
1

我打算在Python for Windows中安装XGBoost包。按照这里提到的说明(How to install xgboost package in python (windows platform)?)后,我在最后一步(python setup.py install)遇到了问题。ImportError:在Windows/Python中安装XGBoost时没有名为numpy.distutils.core的模块

$ python setup.py install --user 
Install libxgboost from: ['..\\lib\\xgboost.dll'] 
running install 
running bdist_egg 
running egg_info 
writing requirements to xgboost.egg-info\requires.txt 
writing xgboost.egg-info\PKG-INFO 
writing top-level names to xgboost.egg-info\top_level.txt 
writing dependency_links to xgboost.egg-info\dependency_links.txt 
reading manifest file 'xgboost.egg-info\SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
warning: no files found matching '*' under directory 'xgboost\include' 
warning: no files found matching '*' under directory 'xgboost\src' 
warning: no files found matching '*' under directory 'xgboost\make' 
warning: no files found matching '*' under directory 'xgboost\rabit' 
warning: no files found matching '*' under directory 'xgboost\lib' 
warning: no files found matching '*' under directory 'xgboost\dmlc-core' 
warning: no previously-included files matching '*.o' found anywhere in distribut                            ion 
warning: no previously-included files matching '*.a' found anywhere in distribut                            ion 
warning: no previously-included files matching '*.pyo' found anywhere in distrib                            ution 
warning: no previously-included files matching '*.pyc' found anywhere in distrib                            ution 
writing manifest file 'xgboost.egg-info\SOURCES.txt' 
installing library code to build\bdist.win32\egg 
running install_lib 
running build_py 
creating build\bdist.win32\egg 
creating build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\build-python.sh -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\callback.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\compat.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\core.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\libpath.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\plotting.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\rabit.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\sklearn.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\training.py -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\VERSION -> build\bdist.win32\egg\xgboost 
copying build\lib\xgboost\__init__.py -> build\bdist.win32\egg\xgboost 
byte-compiling build\bdist.win32\egg\xgboost\callback.py to callback.pyc 
byte-compiling build\bdist.win32\egg\xgboost\compat.py to compat.pyc 
byte-compiling build\bdist.win32\egg\xgboost\core.py to core.pyc 
byte-compiling build\bdist.win32\egg\xgboost\libpath.py to libpath.pyc 
byte-compiling build\bdist.win32\egg\xgboost\plotting.py to plotting.pyc 
byte-compiling build\bdist.win32\egg\xgboost\rabit.py to rabit.pyc 
byte-compiling build\bdist.win32\egg\xgboost\sklearn.py to sklearn.pyc 
byte-compiling build\bdist.win32\egg\xgboost\training.py to training.pyc 
byte-compiling build\bdist.win32\egg\xgboost\__init__.py to __init__.pyc 
installing package data to build\bdist.win32\egg 
running install_data 
copying ..\lib\xgboost.dll -> build\bdist.win32\egg\xgboost 
creating build\bdist.win32\egg\EGG-INFO 
copying xgboost.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO 
copying xgboost.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO 
copying xgboost.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO 
copying xgboost.egg-info\not-zip-safe -> build\bdist.win32\egg\EGG-INFO 
copying xgboost.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO 
copying xgboost.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO 
creating 'dist\xgboost-0.6-py2.7.egg' and adding 'build\bdist.win32\egg' to it 
removing 'build\bdist.win32\egg' (and everything under it) 
Processing xgboost-0.6-py2.7.egg 
creating c:\users\mishraji\appdata\roaming\python\python27\site-packages\xgboost                            -0.6-py2.7.egg 
Extracting xgboost-0.6-py2.7.egg to c:\users\mishraji\appdata\roaming\python\pyt                            hon27\site-packages 
Adding xgboost 0.6 to easy-install.pth file 

Installed c:\users\mishraji\appdata\roaming\python\python27\site-packages\xgboos                            t-0.6-py2.7.egg 
Processing dependencies for xgboost==0.6 
Searching for scipy 
Reading https://pypi.python.org/simple/scipy/ 
Downloading https://pypi.python.org/packages/52/67/d9ef9b5058d4a9e3f0ae641ec1517                            90622cbeb37f157de5773358e2bf3da/scipy-0.19.1.tar.gz#md5=6b4d91b62f1926282b127194                            a06b72b3 
Best match: scipy 0.19.1 
Processing scipy-0.19.1.tar.gz 
Writing c:\users\mishraji\appdata\local\temp\easy_install-cxrtxb\scipy-0.19.1\se                            tup.cfg 
Running scipy-0.19.1\setup.py -q bdist_egg --dist-dir c:\users\mishraji\appdata\                            local\temp\easy_install-cxrtxb\scipy-0.19.1\egg-dist-tmp-hya72r 
c:\users\mishraji\appdata\local\temp\easy_install-cxrtxb\scipy-0.19.1\setup.py:3                            23: UserWarning: Unrecognized setuptools command, proceeding with generating Cyt                            hon sources and expanding templates 
    warnings.warn("Unrecognized setuptools command, proceeding with " 
Traceback (most recent call last): 
    File "setup.py", line 42, in <module> 
    url='https://github.com/dmlc/xgboost') 
    File "C:\Python27\lib\distutils\core.py", line 151, in setup 
    dist.run_commands() 
    File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands 
    self.run_command(cmd) 
    File "C:\Python27\lib\distutils\dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "C:\Python27\lib\site-packages\setuptools\command\install.py", line 67, i                            n run 
    self.do_egg_install() 
    File "C:\Python27\lib\site-packages\setuptools\command\install.py", line 117,                             in do_egg_install 
    cmd.run() 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             410, in run 
    self.easy_install(spec, not self.no_deps) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             646, in easy_install 
    return self.install_item(None, spec, tmpdir, deps, True) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             697, in install_item 
    self.process_distribution(spec, dist, deps) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             742, in process_distribution 
    [requirement], self.local_index, self.easy_install 
    File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 850, in r                            esolve 
    dist = best[req.key] = env.best_match(req, ws, installer) 
    File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 1122, in                             best_match 
    return self.obtain(req, installer) 
    File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 1134, in                             obtain 
    return installer(requirement) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             665, in easy_install 
    return self.install_item(spec, dist.location, tmpdir, deps) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             695, in install_item 
    dists = self.install_eggs(spec, download, tmpdir) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             876, in install_eggs 
    return self.build_and_install(setup_script, setup_base) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             1115, in build_and_install 
    self.run_setup(setup_script, setup_base, args) 
    File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line                             1101, in run_setup 
    run_setup(setup_script, args) 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 251, in run_s                            etup 
    raise 
    File "C:\Python27\lib\contextlib.py", line 35, in __exit__ 
    self.gen.throw(type, value, traceback) 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 198, in setup                            _context 
    yield 
    File "C:\Python27\lib\contextlib.py", line 35, in __exit__ 
    self.gen.throw(type, value, traceback) 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 169, in save_                            modules 
    saved_exc.resume() 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 144, in resum                            e 
    six.reraise(type, exc, self._tb) 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 157, in save_                            modules 
    yield saved 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 198, in setup                            _context 
    yield 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 248, in run_s                            etup 
    DirectorySandbox(setup_dir).run(runner) 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 278, in run 
    return func() 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 246, in runne                            r 
    _execfile(setup_script, ns) 
    File "C:\Python27\lib\site-packages\setuptools\sandbox.py", line 47, in _execf                            ile 
    exec(code, globals, locals) 
    File "c:\users\mishraji\appdata\local\temp\easy_install-cxrtxb\scipy-0.19.1\se                            tup.py", line 416, in <module> 

    File "c:\users\mishraji\appdata\local\temp\easy_install-cxrtxb\scipy-0.19.1\se                            tup.py", line 396, in setup_package 

ImportError: No module named numpy.distutils.core 

但是,当我在python中导入包时,它没有任何问题。

import numpy.distutils.core as np 
+0

他们是否运行相同的python版本?另外,请尝试安装scipy。 –

+0

已经安装了Scipy 0.19.0-1。是的,他们正在运行相同的Python版本2.7 – bkm

+0

嗨ColdSpped,你是对的,我使用的是两个版本的Python。问题解决了。 – bkm

回答

0

由于我有两个python版本(v 2.7.13)和Enthought Canopy(Python 2.7.11),因此问题发生。由于Python 2.7.11已经有了Numpy包,xgboost已经成功安装了。

python setup.py install 
相关问题