2017-08-25 78 views
0

安裝xgboost在安裝從混帳xgboost(其次是「蟒蛇的setup.py安裝」),我得到的控制檯消息,如下圖所示: -問題,同時對蟒蛇

=========

(C:\Users\MUSTHAFA-PC\Anaconda3) C:\Users\MUSTHAFA-PC\xgboost_install_dir\python-package>python setup.py install 
Install libxgboost from: ['xgboost\\xgboost.dll'] 
running install 
running bdist_egg 
running egg_info 
writing xgboost.egg-info\PKG-INFO 
writing requirements to xgboost.egg-info\requires.txt 
writing dependency_links to xgboost.egg-info\dependency_links.txt 
writing top-level names to xgboost.egg-info\top_level.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 distribution 
warning: no previously-included files matching '*.a' found anywhere in distribution 
warning: no previously-included files matching '*.pyo' found anywhere in distribution 
warning: no previously-included files matching '*.pyc' found anywhere in distribution* 
writing manifest file 'xgboost.egg-info\SOURCES.txt' 
installing library code to build\bdist.win-amd64\egg 
running install_lib 
running build_py 
creating build\bdist.win-amd64\egg 
creating build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\build-python.sh -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\callback.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\compat.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\core.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\libpath.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\plotting.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\rabit.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\sklearn.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\training.py -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\VERSION -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\xgboost.dll -> build\bdist.win-amd64\egg\xgboost 
copying build\lib\xgboost\__init__.py -> build\bdist.win-amd64\egg\xgboost 
byte-compiling build\bdist.win-amd64\egg\xgboost\callback.py to callback.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\compat.py to compat.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\core.py to core.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\libpath.py to libpath.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\plotting.py to plotting.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\rabit.py to rabit.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\sklearn.py to sklearn.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\training.py to training.cpython-35.pyc 
byte-compiling build\bdist.win-amd64\egg\xgboost\__init__.py to __init__.cpython-35.pyc 
installing package data to build\bdist.win-amd64\egg 
running install_data 
creating build\bdist.win-amd64\egg\EGG-INFO 
copying xgboost.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO 
copying xgboost.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO 
copying xgboost.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO 
copying xgboost.egg-info\not-zip-safe -> build\bdist.win-amd64\egg\EGG-INFO 
copying xgboost.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO 
copying xgboost.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO 
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt 
creating 'dist\xgboost-0.6-py3.5.egg' and adding 'build\bdist.win-amd64\egg' to it 
removing 'build\bdist.win-amd64\egg' (and everything under it) 
Processing xgboost-0.6-py3.5.egg 
removing 'c:\users\musthafa-pc\anaconda3\lib\site-packages\xgboost-0.6-py3.5.egg' (and everything under it) 
creating c:\users\musthafa-pc\anaconda3\lib\site-packages\xgboost-0.6-py3.5.egg 
Extracting xgboost-0.6-py3.5.egg to c:\users\musthafa-pc\anaconda3\lib\site-packages 
xgboost 0.6 is already the active version in easy-install.pth 

Installed c:\users\musthafa-pc\anaconda3\lib\site-packages\xgboost-0.6-py3.5.egg 
Processing dependencies for xgboost==0.6 
Searching for scipy==0.19.1 
Best match: scipy 0.19.1 
Adding scipy 0.19.1 to easy-install.pth file 

Using c:\users\musthafa-pc\anaconda3\lib\site-packages 
Searching for numpy==1.13.1 
Best match: numpy 1.13.1 
Adding numpy 1.13.1 to easy-install.pth file 

Using c:\users\musthafa-pc\anaconda3\lib\site-packages 
Finished processing dependencies for xgboost==0.6 

(C:\Users\MUSTHAFA-PC\Anaconda3) C:\Users\MUSTHAFA-PC\xgboost_install_dir\python-package> 

==========

我不知道那些警告信息的關鍵性的,但過程似乎沒有錯誤來完成。

但是,當我嘗試在jupyter筆記本( 「進口xgboost」)導入xgboost,具有以下的跟蹤消息出現錯誤: -


OSError         Traceback (most recent call last) 
<ipython-input-1-e81c313a2b5e> in <module>() 
     4 import numpy as np 
     5 import matplotlib.pyplot as plt 
----> 6 import xgboost 

C:\Users\MUSTHAFA-PC\Anaconda3\lib\site-packages\xgboost-0.6-py3.5.egg\xgboost\__init__.py in <module>() 
     9 import os 
    10 
---> 11 from .core import DMatrix, Booster 
    12 from .training import train, cv 
    13 from . import rabit     # noqa 

C:\Users\MUSTHAFA-PC\Anaconda3\lib\site-packages\xgboost-0.6-py3.5.egg\xgboost\core.py in <module>() 
    113 
    114 # load the XGBoost library globally 
--> 115 _LIB = _load_lib() 
    116 
    117 

C:\Users\MUSTHAFA-PC\Anaconda3\lib\site-packages\xgboost-0.6-py3.5.egg\xgboost\core.py in _load_lib() 
    107  if len(lib_path) == 0: 
    108   return None 
--> 109  lib = ctypes.cdll.LoadLibrary(lib_path[0]) 
    110  lib.XGBGetLastError.restype = ctypes.c_char_p 
    111  return lib 

C:\Users\MUSTHAFA-PC\Anaconda3\lib\ctypes\__init__.py in LoadLibrary(self, name) 
    427 
    428  def LoadLibrary(self, name): 
--> 429   return self._dlltype(name) 
    430 
    431 cdll = LibraryLoader(CDLL) 

C:\Users\MUSTHAFA-PC\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error) 
    349 
    350   if handle is None: 
--> 351    self._handle = _dlopen(self._name, mode) 
    352   else: 
    353    self._handle = handle 

OSError: [WinError 126] The specified module could not be found 

顯然,這是不能夠導入DMatrix ,Booster爲「無法找到指定的模塊」。

任何想法如何糾正? 我的python版本是3.5,而xgboost是0.6

回答

0

在導入xgboost之前,需要將g ++運行時庫的路徑添加到os環境路徑變量中。以下代碼有效:

import os 

mingw_path = 'C:\\Program Files\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev0\\mingw64\\bin' 

os.environ['PATH'] = mingw_path + ';' + os.environ['PATH'] 

您可以用自己的目錄替換路徑。