Xgboost: 导入错误:没有名为 numpy.distutils.core 的模块(Ubuntu xgboost 安装)

创建于 2016-02-11  ·  17评论  ·  资料来源: dmlc/xgboost

我是 Ubuntu 的新用户,最近与 Windows 10 一起下载了 Ubuntu 14.04 桌面版。

我的 PC 配置是:4 GB RAM,64 位

我从终端使用以下命令安装了 Anaconda(从网站下载后):
bash Anaconda3-2.5.0-Linux-x86_64.sh

安装成功。

现在在我的 ubuntu 终端中,我按照http://xgboost.readthedocs.org/en/latest/build.html#building -on-ubuntu-debian 上的说明进行操作

  1. 安装了最新的 GNU C++ 编译器 --> 成功
  2. git clone --recursive https://github.com/dmlc/xgboost cd xgboost; make -j4
    构建也很成功,我可以构建“libxgboost.so”
  3. sudo apt-get install python-setuptools (成功)
  4. cd python-package
  5. sudo python setup.py install

5. 命令在若干行后返回错误。 错误如下:

“导入错误:没有名为 numpy.distutils.core 的模块”

任何人都可以建议如何摆脱这个错误,以便我可以安装 xgboost 吗?

第五步后的完整日志如下:

_sidvash@sidvash-HP-Pavilion-g6-Notebook-PC:~/xgboost/python-package$ sudo python setup.py install
从以下位置安装 libxgboost:['/home/sidvash/xgboost/python-package/xgboost/../../lib/libxgboost.so']
运行安装
运行 bdist_egg
运行 egg_info
将需求写入 xgboost.egg-info/requires.txt
编写 xgboost.egg-info/PKG-INFO
将顶级名称写入 xgboost.egg-info/top_level.txt
将dependency_links 写入xgboost.egg-info/dependency_links.txt
读取清单文件“xgboost.egg-info/SOURCES.txt”
阅读清单模板“MANIFEST.in”
警告:在目录“xgboost/include”下找不到与“_”匹配的文件
警告:在目录“xgboost/src”下找不到与“_”匹配的文件
警告:在发行版中的任何地方都找不到与“xgboost/build/_”匹配的先前包含的文件
警告:在发行版中的任何地方都找不到与“xgboost/_.o”匹配的先前包含的文件
警告:在分发中的任何地方都找不到与“_.pyo”匹配的先前包含的文件
警告:在发行版中的任何地方都找不到与“_.pyc”匹配的先前包含的文件
写入清单文件“xgboost.egg-info/SOURCES.txt”
安装库代码到 build/bdist.linux-x86_64/egg
运行 install_lib
运行 build_py
创建 build/bdist.linux-x86_64/egg
创建 build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/libpath.py -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/VERSION -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/build-python.sh -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/__init__.py -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/training.py -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/compat.py -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/core.py -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/sklearn.py -> build/bdist.linux-x86_64/egg/xgboost
复制 build/lib.linux-x86_64-2.7/xgboost/plotting.py -> build/bdist.linux-x86_64/egg/xgboost
字节编译 build/bdist.linux-x86_64/egg/xgboost/libpath.py 到 libpath.pyc
字节编译 build/bdist.linux-x86_64/egg/xgboost/ init .py 到init .pyc
字节编译 build/bdist.linux-x86_64/egg/xgboost/training.py 到 training.pyc
字节编译 build/bdist.linux-x86_64/egg/xgboost/compat.py 到 compat.pyc
字节编译 build/bdist.linux-x86_64/egg/xgboost/core.py 到 core.pyc
字节编译 build/bdist.linux-x86_64/egg/xgboost/sklearn.py 到 sklearn.pyc
字节编译 build/bdist.linux-x86_64/egg/xgboost/plotting.py 到 plotting.pyc
安装包数据到 build/bdist.linux-x86_64/egg
运行 install_data
复制 /home/sidvash/xgboost/python-package/xgboost/../../lib/libxgboost.so -> build/bdist.linux-x86_64/egg/xgboost
创建 build/bdist.linux-x86_64/egg/EGG-INFO
复制 xgboost.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
复制 xgboost.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
复制 xgboost.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
复制 xgboost.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
复制 xgboost.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
复制 xgboost.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
创建“dist/xgboost-0.4-py2.7.egg”并添加“build/bdist.linux-x86_64/egg”
删除“build/bdist.linux-x86_64/egg”(及其下的所有内容)
处理 xgboost-0.4-py2.7.egg
删除“/usr/local/lib/python2.7/dist-packages/xgboost-0.4-py2.7.egg”(以及它下面的所有内容)
创建 /usr/local/lib/python2.7/dist-packages/xgboost-0.4-py2.7.egg
将 xgboost-0.4-py2.7.egg 解压到 /usr/local/lib/python2.7/dist-packages
xgboost 0.4 已经是 easy-install.pth 中的活动版本

安装/usr/local/lib/python2.7/dist-packages/xgboost-0.4-py2.7.egg
处理 xgboost==0.4 的依赖项
寻找 scipy
阅读https://pypi.python.org/simple/scipy/
最佳匹配:scipy 0.17.0
下载https://pypi.python.org/packages/source/s/scipy/scipy-0.17.0.zip#md5 =28a4fe29e980804db162524f10873211
处理 scipy-0.17.0.zip
写/tmp/easy_install-2YPTnH/scipy-0.17.0/setup.cfg
运行 scipy-0.17.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2YPTnH/scipy-0.17.0/egg-dist-tmp-z4NE5c
回溯(最近一次调用最后一次):
文件“setup.py”,第 39 行,在
url='https://github.com/dmlc/xgboost')
设置中的文件“/usr/lib/python2.7/distutils/core.py”,第 151 行
dist.run_commands()
文件“/usr/lib/python2.7/distutils/dist.py”,第 953 行,在 run_commands 中
self.run_command(cmd)
文件“/usr/lib/python2.7/distutils/dist.py”,第 972 行,在 run_command
cmd_obj.run()
运行中的文件“/usr/lib/python2.7/dist-packages/setuptools/command/install.py”,第 73 行
self.do_egg_install()
文件“/usr/lib/python2.7/dist-packages/setuptools/command/install.py”,第 96 行,在 do_egg_install
cmd.run()
运行中的文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第 381 行
self.easy_install(spec, not self.no_deps)
文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第597行,在easy_install中
返回 self.install_item(None, spec, tmpdir, deps, True)
install_item 中的文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第 648 行
self.process_distribution(spec, dist, deps)
文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第694行,在process_distribution
[要求]、self.local_index、self.easy_install
文件“/usr/lib/python2.7/dist-packages/pkg_resources.py”,第620行,解析
dist = best[req.key] = env.best_match(req, ws, installer)
文件“/usr/lib/python2.7/dist-packages/pkg_resources.py”,第 858 行,在 best_match 中
return self.obtain(req, installer) # 尝试下载/安装
文件“/usr/lib/python2.7/dist-packages/pkg_resources.py”,第870行,在获取
返回安装程序(要求)
文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第616行,在easy_install中
返回 self.install_item(spec, dist.location, tmpdir, deps)
install_item 中的文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第 646 行
diss = self.install_eggs(规格,下载,tmpdir)
install_eggs 中的文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第 834 行
返回 self.build_and_install(setup_script, setup_base)
文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第 1040 行,在 build_and_install 中
self.run_setup(setup_script, setup_base, args)
文件“/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py”,第 1025 行,在 run_setup 中
运行设置(设置脚本,参数)
文件“/usr/lib/python2.7/dist-packages/setuptools/sandbox.py”,第50行,在run_setup
拉姆达:执行文件(
运行中的文件“/usr/lib/python2.7/dist-packages/setuptools/sandbox.py”,第 100 行
返回函数()
文件“/usr/lib/python2.7/dist-packages/setuptools/sandbox.py”,第52行,在
{'文件':setup_script,'名称':''}
文件“setup.py”,第 265 行,在

文件“setup.py”,第 253 行,在 setup_package 中

导入错误:没有名为 numpy.distutils`_ 的模块

最有用的评论

如果“pip install xgboost”对您不起作用,也可以通过执行以下操作来解决此问题

sudo -s
python setup.py install 

问题是 'sudo python' 将使用系统的 Python 而不是 anacoda 的 Python。

更多细节: http :

所有17条评论

你确定你使用的是正确的python吗?

尝试

which python

或者

readlink -f `which python`

以确定您是否正在使用 Anaconda。

你好,

感谢您的评论。

which python 返回以下内容:
/home/sidvash/anaconda3/bin/python

@brickerino :我刚刚在描述中的第 5 步之后更新了完整日志。 请看看这是否有帮助。

该消息显示您没有 numpy,请检查您的 PYTHON_PATH 是否指向 anaconda 包路径。 另外,如果还没有,请确保 conda install numpy

@芬特劳
我使用以下命令检查了 python_path:
python -c“导入系统;打印(系统路径)”

返回
['', '/home/sidvash/anaconda3/lib/python35.zip', '/home/sidvash/anaconda3/lib/python3.5', '/home/sidvash/anaconda3/lib/python3.5/plat- linux'、'/home/sidvash/anaconda3/lib/python3.5/lib-dynload'、'/home/sidvash/anaconda3/lib/python3.5/site-packages'、'/home/sidvash/anaconda3/lib /python3.5/site-packages/Sphinx-1.3.5-py3.5.egg', '/home/sidvash/anaconda3/lib/python3.5/site-packages/cryptography-1.0.2-py3.5- linux-x86_64.egg', '/home/sidvash/anaconda3/lib/python3.5/site-packages/setuptools-19.6.2-py3.5.egg']

这对我来说看起来不错。 但是,我在我的第一篇文章中看到路径“/usr/lib/python2.7/dist-packages”出现在错误的多行中,我不确定它是否也应该出现在 python 路径中或不是。 你能提出什么建议吗?

我还运行了“conda install numpy”,它返回了以下内容

使用 Anaconda Cloud api 站点https://api.anaconda.org
获取包元数据:....
解决封装规格:......................
环境/home/sidvash/anaconda3安装包方案:

将下载以下软件包:

| 包| 构建 |
| --- | --- |
| 车轮-0.29.0 | py35_0 82 KB |

以下软件包将被更新:

wheel: 0.26.0-py35_1 --> 0.29.0-py35_0

继续 ([y]/n)? 是

正在获取包裹...
车轮-0.29.0-p 100% |##############################| 时间:0:00:01 50.38 kB/s
提取包...
[完成]|########################################### #####| 100%
正在取消链接包...
[完成]|########################################### #####| 100%
链接包...
[完成]|########################################### #####| 100

安装后尝试 sudo python setup.py install 但没有运气,仍然是同样的错误

好吧,你有来自系统的 python 和 anaconda,以及 python 2 3,而且你有系统的 setuptool,所以一些 env 搞砸了。 我可以建议创建一个 virtualenv 并安装 numpy scikit-learn 和 xgboost

@phunterlau :感谢您的评论。 我真的很感谢你的帮助。

我是 Ubuntu 的新手,不想再把事情搞砸了。

你能告诉我一步一步的过程吗?

我知道我可以使用以下方法创建一个 virtualenv:(不建议使用 conda 安装 virtualenv)
conda create -n <env_name> python=3.5 anaconda

然后我应该如何在这个 env 上安装 numpy scikit-learn 和 xgboost ?

我可以通过以下方式激活环境:
source activate <env_name>

我是否应该继续进行如下进一步的安装:
pip install numpy
pip install scikit-learn

对于 xgboost,我应该重复所有这些步骤吗?
git clone --recursive https://github.com/dmlc/xgboost cd xgboost; make -j4
cd python-package; sudo python setup.py install

好的,所以我做了以下但仍然得到完全相同的错误:
conda create -n snakes python=3.5 numpy pandas scikit-learn
sidvash:~$ source activate snakes
discarding /home/sidvash/anaconda3/bin from PATH
prepending /home/sidvash/anaconda3/envs/snakes/bin to PATH

cd xgboost/python-package
sudo python setup.py install

不知什么原因,安装还是一直引用“/usr/lib/python2.7/dist-packages”

我按照以下步骤进行了整理:

  1. 删除我之前从 github 下载的名为“xgboost”的当前目录。
  2. pip 安装 xgboost

这就像一个魅力。 我之前没有尝试过,因为在 github 站点上提到您应该从 github 安装最新版本。

我在堆栈溢出上发布了这个问题,有人提出了这个建议。 这是链接:
http://stackoverflow.com/questions/35332300/importerror-no-module-named-numpy-distutils-core-ubuntu-xgboost-installation/35493714#35493714

无论如何,非常感谢您的帮助: @brickerino @phunterlau

很高兴pip install xgboost有所帮助:-)

如果“pip install xgboost”对您不起作用,也可以通过执行以下操作来解决此问题

sudo -s
python setup.py install 

问题是 'sudo python' 将使用系统的 Python 而不是 anacoda 的 Python。

更多细节: http :

@knguyen0105对我

@knguyen0105给出错误
“/home/ashish/anaconda2/bin/../lib/libgomp.so.1:未找到版本‘GOMP_4.0’(/home/ashish/anaconda2/lib/python2.7/site-packages/xgboost 需要) /./lib/libxgboost.so)”

有人可以帮忙吗?

PYTHON_PATH应该返回什么?

@knguyen0105对我来说效果很好! 谢谢!

感谢 knguyen0105,Ubuntu 摘要,anaconda 2:

  1. http://xgboost.readthedocs.io/en/latest/build.html
  2. 须藤 -s
    python setup.py 安装
    代替
    cd python 包; 须藤 python setup.py 安装

@knguyen0105,真的非常感谢

此页面是否有帮助?
0 / 5 - 0 等级