Skip to content Skip to sidebar Skip to footer

Module 'xgboost' Has No Attribute 'dmatrix'

I pulled some ML code that ran on kaggle (linux) and tried to run it in a jupyter notebook on a windows machine. Here is the code (some of it): ##### RUN XGBOOST import xgboost as

Solution 1:

We probably have the same problem.

I solved it by telling Python explicitly where to find xgboost library.

The reason is that I have more than one scripts with the name xgboost.py. Python might have imported one of them mistakenly, so that it cannot find the definition of 'DMatrix'.

Here is the command I used:

exportPYTHONPATH=~/xgboost/python-package

You should change '~/xgboost/python-package' into the folder where your /xgboost/python-package/setup.py file located.

Post a Comment for "Module 'xgboost' Has No Attribute 'dmatrix'"