Xgboost在pycharm上工作,但在Jupyter NoteBook中不起作用 [英] Xgboost work on pycharm but not in Jupyter NoteBook

查看:787
本文介绍了Xgboost在pycharm上工作,但在Jupyter NoteBook中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Pycharm Python在Windows中成功安装了Xgboost,并且可以正常工作. 但是,在Jupyter NoteBook中,它无法正常工作.

I've successfully installed Xgboost in windows with Pycharm Python, and it is working. However, in Jupyter NoteBook, it is not working.

        import xgboost as xgb
    ---> 12 import xgboost as xgb
ModuleNotFoundError: No module named 'xgboost'

在Jupyter中,xgboost软件包位于:

In Jupyter the xgboost package is at:

> !pip install xgboost

已经满足要求:c:\ users \ sifangyou \ anaconda3 \ lib \ site-packages \ xgboost-0.6-py3.6.egg中的xgboost

Requirement already satisfied: xgboost in c:\users\sifangyou\anaconda3\lib\site-packages\xgboost-0.6-py3.6.egg

已经满足要求:c:\ users \ sifangyou \ anaconda3 \ lib \ site-packages中的numpy(来自xgboost)

Requirement already satisfied: numpy in c:\users\sifangyou\anaconda3\lib\site-packages (from xgboost)

已经满足要求:c:\ users \ sifangyou \ anaconda3 \ lib \ site-packages中的scipy(来自xgboost)

Requirement already satisfied: scipy in c:\users\sifangyou\anaconda3\lib\site-packages (from xgboost)

但是,我的xgboost安装在: C:\ Users \ sifangyou \ xgboost \ python-package

However, my xgboost is installed in: C:\Users\sifangyou\xgboost\python-package

如何将Jupyter定向到正确的xgboost软件包位置?

How can I direct Jupyter to the correct xgboost package location?

推荐答案

理想情况下,您应该将软件包安装在PYTHONPATH中的位置(python看上去就是).通常pip会执行此操作,但是jupyter和pycharm可能使用不同的版本.试试:

Ideally, you should install packages in the location in your PYTHONPATH (which is where python looks). Usually pip does this, however its possible that jupyter, and pycharm are using different version. Try:

import sys
print sys.executable

import os
print os.environ['PYTHONPATH'].split(os.pathsep)

在pycharm和jupyter中.

in both pycharm and jupyter.

然后您可以尝试以下两种方法之一:

You can then try one of two things:

  1. 使用正确版本的pip安装软件包:

  1. install the package with the right version of pip:

/path/to/python/path/to/pip安装PackageName

/path/to/python /path/to/pip install PackageName

在python中动态破解python路径:

dynamically hacking your python path in python:

:

 import sys
 sys.path.append(r"C:\Users\sifangyou\xgboost\python-package")
 import xgboost

2是否可行取决于安装xgboost时发生了什么魔术. (有可能不运行安装步骤就无法使用).

Whether 2 works depends on what magic happens when xgboost is installed. (Its possible that it may not by usable without running the install steps).

这篇关于Xgboost在pycharm上工作,但在Jupyter NoteBook中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆