Ubuntu 在水蟒身上进口xgboost?

Ubuntu 在水蟒身上进口xgboost?,ubuntu,xgboost,Ubuntu,Xgboost,我使用官方文档在ubuntu上安装xgboost。没有错误,但是当我启动我的ipython笔记本时,它是anaconda环境,import xgboost显示错误,这不是模块 如何在我的anaconda python环境中导入xgboost 我需要修改ubuntu中的一些环境变量吗?在使用Spyder时,同样的事情也发生在我身上。 我可以使用终端(带有弃用警告)导入它,即: 但在尝试使用Spyder运行相同代码时,出现以下错误: pinaki@Excalibur:~$ python

我使用官方文档在ubuntu上安装xgboost。没有错误,但是当我启动我的ipython笔记本时,它是anaconda环境,import xgboost显示错误,这不是模块

如何在我的anaconda python环境中导入xgboost


我需要修改ubuntu中的一些环境变量吗?

在使用Spyder时,同样的事情也发生在我身上。 我可以使用终端(带有弃用警告)导入它,即:

但在尝试使用Spyder运行相同代码时,出现以下错误:

   pinaki@Excalibur:~$ python
   Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:09:58) 
   [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   >>> from xgboost import XGBClassifier
   /home/pinaki/anaconda3/lib/python3.6/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
    "This module will be removed in 0.20.", DeprecationWarning)
    >>>

对我来说,通过将工作文件从xgboost.py重命名为其他文件,这个问题得到了解决。

您必须转到
xgboost
文件夹中的
python package
文件夹,并运行
setup.py

之后

   Requirement already satisfied: xgboost in /home/pinaki/xgboost/python-package
   Requirement already satisfied: numpy in /home/pinaki/anaconda3/lib/python3.6/site-packages (from xgboost)
   Requirement already satisfied: scipy in /home/pinaki/anaconda3/lib/python3.6/site-packages (from xgboost)


请使用conda命令:

conda安装-c conda forge xgboost

使用此conda命令:

或pip:


您可以使用pip:
pip安装xgboost
安装xgboost。
  from xgboost import XGBClassifier
  Traceback (most recent call last):

  File "<ipython-input-1-9b31cfdb821c>", line 1, in <module>
  from xgboost import XGBClassifier

  File "/media/pinaki/MyStuff/Work/Machine Learning A-Z Template Folder/Part 10 - Model Selection & Boosting/Section 49 - XGBoost/XGBoost/xgboost.py", line 30, in <module>
  from xgboost import XGBClassifier

  ImportError: cannot import name 'XGBClassifier'
   Requirement already satisfied: xgboost in /home/pinaki/xgboost/python-package
   Requirement already satisfied: numpy in /home/pinaki/anaconda3/lib/python3.6/site-packages (from xgboost)
   Requirement already satisfied: scipy in /home/pinaki/anaconda3/lib/python3.6/site-packages (from xgboost)
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; make -j4
cd python-package; sudo python setup.py install
conda install -c conda-forge xgboost
pip install xgboost