【问题标题】:python xgboost on mac install在 mac 上安装 python xgboost
【发布时间】:2015-09-29 08:10:54
【问题描述】:

我正在尝试在我的 Mac 上为 Python 3.4 安装 xgboost,但在 pip3 setup.py install 之后出现以下错误:

  File "<string>", line 20, in <module>

  File "/private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost/setup.py", line 28, in <module>

    execfile(libpath_py, libpath, libpath)

NameError: name 'execfile' is not defined

当使用 -v 选项运行它以获得详细输出时,错误如下所示:

  Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost
Exception information:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/commands/install.py", line 339, in run
    requirement_set.prepare_files(finder)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req/req_set.py", line 385, in prepare_files
    req_to_install.run_egg_info()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req/req_install.py", line 358, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/utils/__init__.py", line 749, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost

我该如何解决这个问题?

【问题讨论】:

    标签: python macos installation xgboost


    【解决方案1】:

    这对我有用。

    操作系统:OSX El Capitan

    第一步:cd xgboost; ./build.sh
    第二步:cd python-package; python setup.py install

    【讨论】:

    • 也适用于 OS X Yosemite
    【解决方案2】:

    我认为 xgboost 只是作为 Python 2 包而不是 pip 提供的。 有两种方法可以让它发挥作用。

    1. 您使用 Python 2 并使用 pip 安装它。
    2. 您可以为 Python 3 手动构建 xgboost。只需从 github 下载源代码并构建它:打开终端。从 git 签出:git clone https://github.com/dmlc/xgboost.git。构建它:cd xgboost;制作;光盘包装器; python.py setup install --user

    【讨论】:

    • 2.使用 cd xgboost 为我工作; ./build.sh; python setup.py install --user
    【解决方案3】:

    也许你应该使用

    cd xgboost; cp make/minimum.mk ./config.mk; make -j4
    

    而不是

    cd xgboost; ./build.sh
    

    根据构建文档的“Build On OSX”部分

    也许这是duplicate

    【讨论】:

      【解决方案4】:

      我在尝试按照building from sources 的说明在 Mac OS X Mojave 10.14 上安装 XGBoost 时遇到了很多错误。最糟糕的是当调用 CMake 不起作用并且臭名昭著的 clang: error unsupported option '-fopenmp' 时。真正的 C++ 构建/编译噩梦...

      由于我最终无法编译本机 C++ 库,因此我最终成功使用了此解决方法:

      1. 使用brew获取编译好的库libxgboost.dylib:

        brew install xgboost

        奇怪的是,brew 没有安装整个东西!!??

      2. 安装 Python 库:

        git clone --recursive https://github.com/dmlc/xgboost

        cd xgboost

      3. 安装编译好的库 libxgboost.dylib 并链接到它:

        mkdir lib

        cd lib

        ln -s /usr/local/Cellar/xgboost/0.90/lib/libxgboost.dylib ./libxgboost.dylib

      4. 安装 Python 包

        cd ../python-package

        sudo python3 setup.py install

        同样奇怪的是,setup.py 安装了部分 egg 包,所以我必须手动将 xgboost 包目录复制到 site-packages。

        cp -r xgboost /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/

      对了,我也要升级dask:sudo pip3 install --upgrade dask

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-07-02
        • 1970-01-01
        • 2016-08-26
        • 2017-08-31
        • 2020-11-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多