【发布时间】:2017-04-06 11:24:32
【问题描述】:
当我尝试从 python 终端导入时,我收到了这个错误,虽然我按照所有步骤安装 xgboost,但不知何故 python 无法获取包详细信息。我对 python 比较陌生,我可以轻松安装 numpy 和 pandas 包,我用这个链接在MACOSX上安装http://xgboost.readthedocs.io/en/latest/build.html
>>> import xgboost
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xgboost
当我执行 pip install xgboost 时,我收到了这个错误,
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/h7/pyph_7qj6171tqp50cf2xc7m0000gn/T/pip-build-TEvbD6/xgboost/
我在打印系统路径上得到这个,
打印系统路径
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2. 7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2. 7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/版本/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/ Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/ lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']
【问题讨论】:
-
嗯,模块在那里,但没有这样的类。也许它在一个子模块中?例如
from xgboost.xgbclassifier import XGBClassifier -
你没有将本地文件命名为
xgboost.py,是吗? -
ImportError: No module named 'xgboost.xgbclassifier',我尝试使用你的命令,它返回了这个。
-
@JohnGordon 不!在 jupyter notebook 上运行,文件名不同。我是 python 新手,我需要导入分类器
-
如果连xgboost都导入不了,那肯定是安装出错了。你是在哪个目录下安装的?