Python Anaconda Windows 10的XGBoost安装问题(2018年5月18日)

卡尔·贝克

在过去的几天里,我尝试使用位于以下位置的说明来安装XGBoost

有些指令是直接的(例如conda install -c conda-forge xgboost)。其他步骤涉及几十个步骤,其中一些步骤对于像我这样的新手来说尚不清楚且令人困惑。

某些安装似乎可以正常工作,但是将模块导入jupyter笔记本电脑失败。例如,我可以在看到安装的文件...\Anaconda2\envs\py36\Lib\site-packages\xgboost-0.71-py3.6.egg\xgboost,但是导入会产生错误。

我的最新尝试,随后张贴在说明https://www.kaggle.com/general/30163#latest-330213conda install -c anaconda py-xgboost

同样,安装似乎可以正常进行:我可以在下看到安装的文件...\Anaconda2\envs\py36\Lib\site-packages\xgboost但是在我的笔记本中,当我尝试同时使用

from xgboost import XGBRegressor

import xgboost

我懂了 OSError: [WinError 126] The specified module could not be found error.

完整的回溯如下。

有解决办法吗?更好的安装方式?我想继续观看Dan Becker关于kaggle的ML简介!

版本:

 python version : 3.6.4150.1013
  conda version : 4.3.30

  Microsoft Windows : Version 10.0.16299.431
           platform : win-64
           git bash : launches a window labeled `MINGW64:/c/users/karls`

追溯:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-7-15d947748610> in <module>()
----> 1 from xgboost import XGBRegressor   # OSError: [WinError 126] The specified module could not be found
      2 
      3 my_model = XGBRegressor()
      4 # Add silent=True to avoid printing out updates with each cycle
      5 my_model.fit(train_X, train_y, verbose=False)

~\Anaconda2\envs\py36\lib\site-packages\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

~\Anaconda2\envs\py36\lib\site-packages\xgboost\core.py in <module>()
    113 
    114 # load the XGBoost library globally
--> 115 _LIB = _load_lib()
    116 
    117 

~\Anaconda2\envs\py36\lib\site-packages\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

~\Anaconda2\envs\py36\lib\ctypes\__init__.py in LoadLibrary(self, name)
    424 
    425     def LoadLibrary(self, name):
--> 426         return self._dlltype(name)
    427 
    428 cdll = LibraryLoader(CDLL)

~\Anaconda2\envs\py36\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    346 
    347         if handle is None:
--> 348             self._handle = _dlopen(self._name, mode)
    349         else:
    350             self._handle = handle

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

编辑1安装尝试

示例1:conda install -c anaconda py-xgboost

  1. 启动Anaconda提示
  2. 激活py36
  3. 运行conda install -c anaconda py-xgboost

这是几天前我尝试进行此安装时的命令窗口结果(当我今天追溯这些步骤时,在“所有已安装的请求软件包”确认下):

(py36) C:\Users\karls>conda install -c anaconda py-xgboost
Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment C:\Users\karls\Anaconda2\envs\py36:

The following packages will be UPDATED:

    bzip2:        1.0.6-haa5b126_2        --> 1.0.6-vc14_3          anaconda [vc14]

The following packages will be SUPERSEDED by a higher-priority channel:

    cryptography: 2.1.4-py36he1d7878_0    --> 2.0.3-py36h123decb_1  anaconda
    curl:         7.58.0-h7602738_0       --> 7.55.1-vc14hdaba4a4_3 anaconda [vc14]
    freetype:     2.8-h51f8f2c_1          --> 2.8-vc14h17c9bdf_0    anaconda [vc14]
    hdf5:         1.10.1-h98b8871_1       --> 1.10.1-vc14hb361328_0 anaconda [vc14]
    icu:          58.2-ha66f8fd_1         --> 58.2-vc14hc45fdbb_0   anaconda [vc14]
    jpeg:         9b-hb83a4c4_2           --> 9b-vc14h4d7706e_1     anaconda [vc14]
    libiconv:     1.15-h1df5818_7         --> 1.15-vc14h29686d3_5   anaconda [vc14]
    libpng:       1.6.34-h79bbb47_0       --> 1.6.32-vc14h5163883_3 anaconda [vc14]
    libssh2:      1.8.0-hd619d38_4        --> 1.8.0-vc14hcf584a9_2  anaconda [vc14]
    libtiff:      4.0.9-h0f13578_0        --> 4.0.8-vc14h04e2a1e_10 anaconda [vc14]
    libxml2:      2.9.7-h79bbb47_0        --> 2.9.4-vc14h8fd0f11_5  anaconda [vc14]
    libxslt:      1.1.32-hf6f1972_0       --> 1.1.29-vc14hf85b8d4_5 anaconda [vc14]
    lxml:         4.2.1-py36heafd4d3_0    --> 4.1.1-py36he0adb16_0  anaconda
    lzo:          2.10-h6df0209_2         --> 2.10-vc14h0a64fa6_1   anaconda [vc14]
    openssl:      1.0.2n-h74b6da3_0       --> 1.0.2l-vc14hf4c37d5_5 anaconda [vc14]
    pillow:       5.0.0-py36h0738816_0    --> 4.2.1-py36hdb25ab2_0  anaconda
    py-xgboost:   0.71-py36h6538335_0     --> 0.71-py36h6538335_0   anaconda
    pycurl:       7.43.0.1-py36h74b6da3_0 --> 7.43.0-py36h086bf4c_3 anaconda
    pyopenssl:    17.5.0-py36h5b7d817_0   --> 17.4.0-py36h3316aad_0 anaconda
    qt:           5.6.2-vc14h6f8c307_12   --> 5.6.2-vc14h6f8c307_12 anaconda [vc14]
    sqlite:       3.22.0-h9d3ae62_0       --> 3.20.1-vc14h7ce8c62_1 anaconda [vc14]
    tk:           8.6.7-hcb92d03_3        --> 8.6.7-vc14hb68737d_1  anaconda [vc14]
    yaml:         0.1.7-hc54c509_2        --> 0.1.7-vc14hb31d195_1  anaconda [vc14]
    zlib:         1.2.11-h8395fce_2       --> 1.2.11-vc14h1cdd9ab_1 anaconda [vc14]

Proceed ([y]/n)?

我输入y,输入Enter,模块已安装。我没有复制结果,但是它表明成功了-但是当我尝试将其导入笔记本时找不到该moducle。

这是我今天再次采取这些步骤时的结果:

(C:\Users\karls\Anaconda2) C:\Users\karls>activate py36

(py36) C:\Users\karls>conda install -c anaconda py-xgboost
Fetching package metadata ...............
Solving package specifications: .

# All requested packages already installed.
# packages in environment at C:\Users\karls\Anaconda2\envs\py36:
#
py-xgboost                0.71             py36h6538335_0    anaconda

(py36) C:\Users\karls>

Anaconda2 \ envs \ py36 \ Lib \ site-packages \ xgboost

Anaconda2 \ envs \ py36 \ Lib \ site-packages \ xgboost__pycache__

编辑2示例2: XGBOOST 0.71安

XGBOOST 0.71乙

XGBOOST 0.71摄氏度

卡尔·贝克

I found an install process that seems to be working in jupyter notebook with Anaconda 4.3 for python 3.6.4 on Windows 10 win-64. Below I spell out the process that I followed. At the bottom I include a couple screenshots of the installed folders and files. If you have any suggestions on how to improve this process, please let me know.

This process is adapted from instructions at http://adataanalyst.com/machine-learning/installing-xgboost-for-windows-10/ which in turn are derived from http://stackoverflow.com/questions/33749735/how-to-install-xgboost-package-in-python-windows-platform.

PREP

  1. If you don’t have git, install it and add it to your PATH.

  2. As part of previous attempts to install xgboost I had recently updated numpy and scipy to latest versions

  3. Download and install MinGW-64: http://sourceforge.net/projects/mingw-w64/

    a. In the Setting dialog, set the Architecture to “x86_64” (was i686) and the Threads to “win32” (was posix)

    b. I installed MinGW-64 to the default file path in C:\Program Files, so I added C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin to my PATH environment variable

    c. After installation finished, as suggested I went to the mingw64\bin folder and renamed mingw32-make to make

    • Actually, I made a copy of mingw32-make and named the copy make

    • Doing so may be the source of some of my troubles below, though I was able to get past them. I recommend you try renaming the file rather than leaving two copies of the same file with different names as I did

GET THE XGBOOST SOURCE CODE

  1. Launch a Windows command prompt: Start | Windows System | Command Prompt

    • These steps may also work in MINGW64, which I switch to later, but here I try to faithfully record the steps I took as I followed the instructions I had)

    a. Enter cd c:\ where c:\ represents the location that you want to install xgboost. For me it was C:\...\Anaconda2\envs\py36\Lib\site-packages

    b. Enter git clone --recursive https://github.com/dmlc/xgboost

    • This will run and output a few dozen lines of output before displaying the prompt for the next step

    c. Enter cd xgboost

    d. Enter git submodule init

    • This did not produce any output and immediately displayed the prompt again

    e. Enter git submodule update

    • This did not produce any output and immediately displayed the prompt again

    f. Enter copy make\mingw64.mk config.mk

    • Output: "1 file(s) copied."

    • NOTE: Up to this point all commands were run in Windows command prompt. The next did not work there, so going forward I switched to the mingw64 terminal. I re-ran step "f" and continued at the next step.

  2. Launch the mingw64 terminal: Start | MinGW--W64 project | Run terminal

    a. Enter cd C:\Users\karls\Anaconda2\envs\py36\Lib\site-packages\xgboost

    b. Enter copy make\mingw64.mk config.mk

    c. Enter make -j4

    • This command did not work. I tried dozens of variations based on suggested I googled: make.exe, makefile, cmake, pymake, make.py, mingw64-make, mingw64-make.exe, C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\make, the list goes on. Nothing worked. I tried changing the directory to other folders inside of site-packages\xgboost. Finally, though the output was suspect, I hit upon the following and was able to proceed.

    d. Change directory to ...\site-packages\xgboost\make

    e. Enter mingw64.mk -j4

    • This popped up a "How do you want to open this file?" dialog, which was the most hopeful output I had seen yet. I did not open the file. Did the command do any good? I have no idea, but I went on to the next steps.

INSTALL THE PYTHON PACKAGE

f. Change directory to site-packages\xgboost\python-package

g. Enter python setup.py install

  • This outputs several dozen lines: running this, creating that, writing and reading and copying, etc.

  • I also had several "warning: no files found matching ..." lines.

  • Presumably anything missing was dealt with in the followed lines of more writing, installing, running, creating, copying, byte-compiling, removing, processing, extracting, adding, and searching

  • The final line read "Finished processing dependencies for xgboost==0.71"

至此,我已经能够在jupyter笔记本中导入和使用xgboost,因此我没有采取任何进一步的措施。但是,我遵循的说明(上面已链接)包括您可能会发现需要的其他步骤。如果您在处理过程中遇到任何错误,请告诉我,因为我仍然怀疑我的安装对以后的更新问题不敏感(例如,该目录似乎在多个位置包含相同文件的副本)。

以下是已安装目录的几个屏幕截图:

xgboost安装的文件夹文件 xgboost安装的文件

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Python-如何在Windows 10上完全卸载Anaconda?

如何检查Windows 10 PC上安装的python anaconda版本?

如何在Anaconda Python(Windows平台)中安装xgboost?

Anaconda Python安装错误

Windows上Anaconda Python在哪里安装?

Windows上使用Python 3.5 Anaconda的底图

如何在Windows的Anaconda Python中安装Keras和Theano?

游民安装Anaconda Python?

Anaconda Python 3.5安装PyODBC

在python,Windows Anaconda中找不到Chromedriver

在Windows上安装python库时出现问题:CondaHTTPError:URL <https://conda.anaconda.org/anaconda/win-64的HTTP 000连接失败

在Anaconda python 3. Windows 10-64上安装Scapy

Anaconda Python3.5 Windows Gdal安装

如何在Windows 10中从Anaconda 3删除Python环境

Anaconda始终安装Python 3.7

在Anaconda Windows安装下运行网状问题

无法从Windows 10中的python 3 anaconda python中的集合导入计数器

如果通过Anaconda安装Python,如何通过Windows cmd安装模块?

如何使用Anaconda在Windows上为python安装ipopt

在Windows 10上通过Anaconda安装python3.7的networkx v2.4

Anaconda中的python环境问题

在Anaconda Python(Windows)中安装Matlab引擎

使用anaconda发行版安装python-igraph(Windows)

Python(Anaconda安装)

使用 Windows 10 anaconda python 2.7 安装 tensorflow CPU

Windows:cx_Oracle 5.3 安装与 Python (Anaconda) 冲突

在 Windows 中使用 Pip Python 3.5 anaconda 安装 tensorflow

Pip 安装 - 安装包 Python 2.7 Anaconda / Windows 10 时的错误消息

在 Windows 10 中安装 Anaconda 3 python 3.6 版本