简体   繁体   English

mac 上的 python xgboost 安装

[英]python xgboost on mac install

I am trying to install xgboost on my Mac for Python 3.4 but I'm getting the following error after pip3 setup.py install :我正在尝试在 Mac 上为 Python 3.4 安装 xgboost,但在pip3 setup.py installpip3 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

When running it with the -v option to get the verbose output the error looks like this:使用 -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

How can I solve this issue?我该如何解决这个问题?

This worked for me.这对我有用。

OS: OSX El Capitan操作系统:OSX El Capitan

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

I think that xgboost is just available as Python 2 package over pip.我认为 xgboost 仅作为 Python 2 包通过 pip 提供。 There are two possibilities to get it working.有两种可能性可以让它工作。

  1. You use Python 2 and install it with pip.您使用 Python 2 并通过 pip 安装它。
  2. You can manually build xgboost for Python 3. Just download the source from github and build it: Open Terminal.您可以为 Python 3 手动构建 xgboost。只需从 github 下载源代码并构建它:打开终端。 check out from git: git clone https://github.com/dmlc/xgboost.git .从 git 中查看: git clone https://github.com/dmlc/xgboost.git build it: cd xgboost;构建它: cd xgboost; make;制作; cd wrapper;光盘包装器; python.py setup install --user python.py setup install --user

perhaps you should use也许你应该使用

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

instead of代替

cd xgboost; ./build.sh

as per the "Build On OSX" Section of build document根据构建文档的“Build On OSX”部分

also perhaps this is a duplicate也可能这是重复的

I've got many errors trying to install XGBoost on a Mac OS X Mojave 10.14 following the instructions building from sources .我尝试按照从源代码构建的说明在 Mac OS X Mojave 10.14 上安装 XGBoost 时遇到很多错误。 The worst one was when invoking CMake didn't work and the infamous clang: error unsupported option '-fopenmp'.最糟糕的是当调用 CMake 不起作用和臭名昭著的 clang: error unsupported option '-fopenmp' 。 A real C++ build / compilation nightmare...一个真正的 C++ 构建/编译噩梦......

Since I was not able to compile the native C++ library finally I succeeded using this workaround procedure:由于我最终无法编译本机 C++ 库,因此我成功地使用了以下解决方法:

  1. Using brew to get the compiled library libxgboost.dylib:使用brew获取编译库libxgboost.dylib:

    brew install xgboost

    Strangely enough, brew didn't install the whole thing!!??奇怪的是,brew 没有安装整个东西!??

  2. Install the Python library:安装 Python 库:

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

    cd xgboost

  3. Install the compiled library libxgboost.dylib and link to it:安装编译库 libxgboost.dylib 并链接到它:

    mkdir lib

    cd lib

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

  4. Install the Python package安装 Python 包

    cd ../python-package

    sudo python3 setup.py install

    Again, strangely enough, setup.py installs partially the egg package, so I have to copy manually the xgboost package directory to site-packages.同样,奇怪的是,setup.py 部分安装了 egg 包,所以我必须手动将 xgboost 包目录复制到 site-packages。

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

By the way, I've also to upgrade dask: sudo pip3 install --upgrade dask顺便说一句,我还升级了 dask: sudo pip3 install --upgrade dask

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM