[英]XGBoost installation issues for Python Anaconda Windows 10 (18 May 2018)
Over the past several days I have tried to install XGBoost using instructions found at 在过去的几天里,我尝试使用上面的说明安装XGBoost
Some of the instructions were straighforward (eg, conda install -c conda-forge xgboost
). 一些说明是直截了当的(例如,conda conda install -c conda-forge xgboost
)。 Others involved a few dozen steps, some of which were unclear and confusing for a novice like me. 其他人涉及几十个步骤,其中一些步骤不清楚并且像我这样的新手感到困惑。
Some of the installations seemed to work, but importing the module in a jupyter notebook failed. 有些安装似乎有效,但在jupyter笔记本中导入模块失败了。 For example, I can see installed files at ...\\Anaconda2\\envs\\py36\\Lib\\site-packages\\xgboost-0.71-py3.6.egg\\xgboost
, but importing produces an error. 例如,我可以在...\\Anaconda2\\envs\\py36\\Lib\\site-packages\\xgboost-0.71-py3.6.egg\\xgboost
看到已安装的文件,但导入会产生错误。
My latest attempt followed instructions posted at https://www.kaggle.com/general/30163#latest-330213 : conda install -c anaconda py-xgboost
. 我的最新尝试按照https://www.kaggle.com/general/30163#latest-330213上的说明进行: conda install -c anaconda py-xgboost
。
Again, the installation seemed to work: I can see the installed files under ...\\Anaconda2\\envs\\py36\\Lib\\site-packages\\xgboost
. 再次,安装似乎工作:我可以看到...\\Anaconda2\\envs\\py36\\Lib\\site-packages\\xgboost
下安装的文件。 But in my notebook when I try to import the module using both 但在我的笔记本中,当我尝试使用两者导入模块时
from xgboost import XGBRegressor
and 和
import xgboost
I get OSError: [WinError 126] The specified module could not be found error.
我得到OSError: [WinError 126] The specified module could not be found error.
The full traceback is below. 完整的回溯如下。
Is there a fix for this? 有没有解决这个问题? A better way to install? 更好的安装方式? I'd like to continue with Dan Becker's intro to ML on kaggle! 我想继续Dan Becker介绍疯狂的ML!
VERSIONS: 版本:
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`
TRACEBACK: 追溯:
---------------------------------------------------------------------------
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
EDIT 1 Install attempts 编辑1 安装尝试
Example 1: conda install -c anaconda py-xgboost 示例1:conda install -c anaconda py-xgboost
Here are the command window results when I tried this install a few days ago (and below the "All requested packages already installed" confirmation when I retraced these steps today): 以下是我几天前尝试此安装时的命令窗口结果(当我今天回溯这些步骤时,在“已安装所有请求的软件包”下面确认):
(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)?
I entered y, Enter and the module was installed. 我输入了y,回车并安装了模块。 I didn't copy the results, but it indicated success -- but the moducle was not found when I tried to import it in a notebook. 我没有复制结果,但它表示成功 - 但是当我尝试在笔记本中导入时没有找到模块。
Here are the results when I took these steps again today: 以下是我今天再次采取这些步骤的结果:
(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>
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. 我在Windows 10 win-64上发现了一个安装过程似乎在jupyter笔记本上使用Anaconda 4.3 for python 3.6.4。 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 . 此过程根据http://adataanalyst.com/machine-learning/installing-xgboost-for-windows-10/上的说明进行调整,而后者又来自http://stackoverflow.com/questions/33749735/how-to -install-xgboost-package-in-python-windows-platform 。
PREP PREP
If you don't have git, install it and add it to your PATH. 如果您没有git,请安装它并将其添加到PATH中。
As part of previous attempts to install xgboost I had recently updated numpy and scipy to latest versions 作为之前尝试安装xgboost的一部分,我最近更新了numpy和scipy到最新版本
Download and install MinGW-64: http://sourceforge.net/projects/mingw-w64/ 下载并安装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) 在设置对话框中,将架构设置为“x86_64”(是i686),将线程设置为“win32”(是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 我将MinGW-64安装到C:\\ Program Files中的默认文件路径,所以我将C:\\ Program Files \\ mingw-w64 \\ x86_64-8.1.0-win32-seh-rt_v6-rev0 \\ mingw64 \\ bin添加到我的PATH环境变量
c. C。 After installation finished, as suggested I went to the mingw64\\bin
folder and renamed mingw32-make
to make
安装完成后,按照建议我去了mingw64\\bin
文件夹mingw64\\bin
命名mingw32-make
来make
Actually, I made a copy of mingw32-make
and named the copy make
其实,我做了一个拷贝 mingw32-make
,并命名为副本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 获取XGBOOST源代码
Launch a Windows command prompt: Start | 启动Windows命令提示符:开始| Windows System | Windows系统| Command Prompt 命令提示符
a. 一种。 Enter cd c:\\
where c:\\
represents the location that you want to install xgboost. 输入cd c:\\
,其中c:\\
表示要安装xgboost的位置。 For me it was C:\\...\\Anaconda2\\envs\\py36\\Lib\\site-packages
对我来说,它是C:\\...\\Anaconda2\\envs\\py36\\Lib\\site-packages
b. 湾 Enter git clone --recursive https://github.com/dmlc/xgboost
输入git clone --recursive https://github.com/dmlc/xgboost
c. C。 Enter cd xgboost
输入cd xgboost
d. d。 Enter git submodule init
输入git submodule init
e. 即 Enter git submodule update
输入git submodule update
f. F。 Enter copy make\\mingw64.mk config.mk
输入copy make\\mingw64.mk config.mk
Output: "1 file(s) copied." 输出:“1个文件被复制。”
NOTE: Up to this point all commands were run in Windows command prompt. 注意:到目前为止,所有命令都在Windows命令提示符下运行。 The next did not work there, so going forward I switched to the mingw64 terminal. 下一个没有在那里工作,所以继续我切换到mingw64终端。 I re-ran step "f" and continued at the next step. 我重新跑步“f”并继续下一步。
Launch the mingw64 terminal: Start | 启动mingw64终端:开始| MinGW--W64 project | MinGW - W64项目| Run terminal 运行终端
a. 一种。 Enter cd C:\\Users\\karls\\Anaconda2\\envs\\py36\\Lib\\site-packages\\xgboost
输入cd C:\\Users\\karls\\Anaconda2\\envs\\py36\\Lib\\site-packages\\xgboost
b. 湾 Enter copy make\\mingw64.mk config.mk
输入copy make\\mingw64.mk config.mk
c. C。 Enter make -j4
输入make -j4
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. 我尝试了几十种基于我用Google搜索的变体: 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
,列表继续。 Nothing worked. 没有任何效果。 I tried changing the directory to other folders inside of site-packages\\xgboost
. 我尝试将目录更改为site-packages\\xgboost
其他文件夹。 Finally, though the output was suspect, I hit upon the following and was able to proceed. 最后,虽然输出是可疑的,但是我点击了以下内容并且能够继续。 d. d。 Change directory to ...\\site-packages\\xgboost\\make
将目录更改为...\\site-packages\\xgboost\\make
e. 即 Enter mingw64.mk -j4
输入mingw64.mk -j4
INSTALL THE PYTHON PACKAGE 安装PYTHON包装
f. F。 Change directory to site-packages\\xgboost\\python-package
将目录更改为site-packages\\xgboost\\python-package
g. G。 Enter python setup.py install
输入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" 最后一行读作“xgboost的完成处理依赖关系== 0.71”
At this point I was able to import and use xgboost in a jupyter notebook, so I did not take any further steps. 此时我能够在jupyter笔记本中导入和使用xgboost,所以我没有采取任何进一步的措施。 However, the instructions I was following (linked above) included additional steps that you may find necessary. 但是,我所遵循的说明(上面链接)包括您可能需要的其他步骤。 Please let me know if you see any errors in my process as I am still suspect that my install is unsusceptible to problems with updates later (for example, the directory seems to contain copies of the same files in multiple places). 如果您在我的过程中发现任何错误,请告诉我,因为我仍然怀疑我的安装后来不易受到更新问题的影响(例如,该目录似乎包含多个位置的相同文件的副本)。
Below are a couple screenshots of the installed directories: 以下是已安装目录的几个屏幕截图:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.