更新时间:2023-12-01 08:03:46
我们可能有相同的问题.
We probably have the same problem.
我通过明确告诉Python在哪里找到xgboost库来解决它.
I solved it by telling Python explicitly where to find xgboost library.
原因是我有多个脚本,名称为xgboost.py. Python可能错误地导入了其中一个,因此找不到'DMatrix'的定义.
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'.
这是我使用的命令:
export PYTHONPATH=~/xgboost/python-package
您应将〜/xgboost/python-package"更改为/xgboost/python-package/setup.py文件所在的文件夹.
You should change '~/xgboost/python-package' into the folder where your /xgboost/python-package/setup.py file located.