ParrotPrediction / docker-course-xgboost

Materials for an online-course - "Practical XGBoost in Python"
http://education.parrotprediction.teachable.com/courses/practical-xgboost-in-python
217 stars 136 forks source link

Unable to import XG boost #5

Closed akshayuppal3 closed 6 years ago

akshayuppal3 commented 6 years ago

Im unable to import XG boost in the python notebook import xgboost

Error in Notebook:

OSError Traceback (most recent call last)

in () ----> 1 import xgboost ~\Anaconda3\lib\site-packages\xgboost-0.6-py3.6.egg\xgboost\__init__.py in () 9 import os 10 ---> 11 from .core import DMatrix, Booster 12 from .training import train, cv 13 from . import rabit # noqa ~\Anaconda3\lib\site-packages\xgboost-0.6-py3.6.egg\xgboost\core.py in () 113 114 # load the XGBoost library globally --> 115 _LIB = _load_lib() 116 117 ~\Anaconda3\lib\site-packages\xgboost-0.6-py3.6.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 ~\Anaconda3\lib\ctypes\__init__.py in LoadLibrary(self, name) 424 425 def LoadLibrary(self, name): --> 426 return self._dlltype(name) 427 428 cdll = LibraryLoader(CDLL) ~\Anaconda3\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 ![capture](https://user-images.githubusercontent.com/25509837/33111356-9edb8040-cf1b-11e7-87f9-5eb6d735d74e.PNG)
akshayuppal3 commented 6 years ago

I found solutions by looking at the following posts

https://github.com/dmlc/xgboost/issues/1644 https://stackoverflow.com/questions/18138635/mingw-exe-requires-a-few-gcc-dlls-regardless-of-the-code

When I created mingw-w64 in the C:\mingw-w64 location then it works and by adding following lines to the notebook

import os mingw_path = 'C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin' os.environ['PATH'] = mingw_path + ';' + os.environ['PATH']

image