我安装了xgboost,但对于我的生活,我无法弄清楚为什么我不能用Python导入它。我已经尝试了我在网上找到的所有东西,但仍然无法让xgboost在我的Windows 10 64位系统上使用Python 3.5。
首先我尝试pip install xgboost
;它说已经安装了xgboost。
>pip install xgboost
Requirement already satisfied: xgboost in c:\users\h473\appdata\local\programs\python\python35\lib\site-packages (0.72)
Requirement already satisfied: numpy in c:\users\h473\appdata\local\programs\python\python35\lib\site-packages (from xgboost) (1.14.3)
Requirement already satisfied: scipy in c:\users\h473\appdata\local\programs\python\python35\lib\site-packages (from xgboost) (1.0.1)
但是当我尝试import xgboost
时,我收到以下错误:
>python
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xgboost
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\site-packages\xgboost\__init__.py", line 11, in <module>
from .core import DMatrix, Booster
File "C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\site-packages\xgboost\core.py", line 115, in <module>
_LIB = _load_lib()
File "C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\site-packages\xgboost\core.py", line 109, in _load_lib
lib = ctypes.cdll.LoadLibrary(lib_path[0])
File "C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\ctypes\__init__.py", line 429, in LoadLibrary
return self._dlltype(name)
File "C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\ctypes\__init__.py", line 351, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
>>>
所以我在Python的site-packages
中添加了xgboost安装到Path环境变量的路径。然后我再次尝试import xgboost
。同样的错误。
然后我卸载了xgboost并尝试从here安装预编译的whl文件。再说它安装成功,但是当我尝试导入它时,我得到了同样的错误。
然后我尝试使用python setup.py install
方法从Github安装,并再次安装,但在导入时会出现同样的错误。
然后我找到了this解决方案,我下载并安装了Visual Studio和cmake。但是在步骤3中,当我尝试执行以下操作时:
cmake .. -G"Visual Studio 15 2017 Win64"
它抛出一个错误,说cmake找不到Visual Studio。
>cmake .. -G"Visual Studio 15 2017"
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/h473/xgboost_dir/build/CMakeFiles/CMakeOutput.log".
C:\Users\h473\xgboost_dir\build>cmake .. -G"Visual Studio 15 2017 Win64"
CMake Error: Error: generator : Visual Studio 15 2017 Win64
Does not match the generator used previously: Visual Studio 15 2017
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
C:\Users\h473\xgboost_dir\build>cmake .. -G"Visual Studio 15 2017 Win64"
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/h473/xgboost_dir/build/CMakeFiles/CMakeOutput.log".
我searched在线修复此问题,但找不到任何有用的信息。
我现在变得非常沮丧,这个该死的东西正在产生的错误的污水池。有人可以尝试任何解决方案吗?