需要安装cmake 3.13或更高版本的Ubuntu PIP。您运行的是xgboost的3.10.2版本,ubuntupip,CMake313orhigherisrequiredYouarerunni

今天在装xgboost的时候出现了下面的错误:

 INFO:XGBoost build_ext:Building from source. /tmp/pip-install-elc4qdig/lib/libxgboost.so
    INFO:XGBoost build_ext:Run CMake command: ['cmake', 'xgboost', '-GUnix Makefiles', '-DUSE_OPENMP=1', '-DUSE_CUDA=0', '-DUSE_NCCL=0', '-DBUILD_WITH_SHARED_NCCL=0', '-DHIDE_CXX_SYMBOLS=1', '-DUSE_HDFS=0', '-DUSE_AZURE=0', '-DUSE_S3=0', '-DPLUGIN_LZ4=0', '-DPLUGIN_DENSE_PARSER=0']
    CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
      CMake 3.13 or higher is required.  You are running version 3.10.2


    -- Configuring incomplete, errors occurred!
    WARNING:XGBoost build_ext:Disabling OpenMP support.
    INFO:XGBoost build_ext:Run CMake command: ['cmake', 'xgboost', '-GUnix Makefiles', '-DUSE_OPENMP=1', '-DUSE_CUDA=0', '-DUSE_NCCL=0', '-DBUILD_WITH_SHARED_NCCL=0', '-DHIDE_CXX_SYMBOLS=1', '-DUSE_HDFS=0', '-DUSE_AZURE=0', '-DUSE_S3=0', '-DPLUGIN_LZ4=0', '-DPLUGIN_DENSE_PARSER=0']
    CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
      CMake 3.13 or higher is required.  You are running version 3.10.2


    -- Configuring incomplete, errors occurred!
    Traceback (most recent call last):
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 160, in build_cmake_extension
        self.build(src_dir, build_dir, gen, build_tool, use_omp=1)
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 110, in build
        subprocess.check_call(cmake_cmd, cwd=build_dir)
      File "/home/wugaosheng/anaconda3/lib/python3.7/subprocess.py", line 341, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'xgboost', '-GUnix Makefiles', '-DUSE_OPENMP=1', '-DUSE_CUDA=0', '-DUSE_NCCL=0', '-DBUILD_WITH_SHARED_NCCL=0', '-DHIDE_CXX_SYMBOLS=1', '-DUSE_HDFS=0', '-DUSE_AZURE=0', '-DUSE_S3=0', '-DPLUGIN_LZ4=0', '-DPLUGIN_DENSE_PARSER=0']' returned non-zero exit status 1.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 317, in 
        url='https://github.com/dmlc/xgboost')
      File "/home/wugaosheng/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 257, in run
        super().run()
      File "/home/wugaosheng/anaconda3/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/wugaosheng/anaconda3/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run
        _build_ext.run(self)
      File "/home/wugaosheng/anaconda3/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
        _build_ext.build_ext.run(self)
      File "/home/wugaosheng/anaconda3/lib/python3.7/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/home/wugaosheng/anaconda3/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
        self.build_extension(ext)
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 168, in build_extension
        self.build_cmake_extension()
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 163, in build_cmake_extension
        self.build(src_dir, build_dir, gen, build_tool, use_omp=0)
      File "/tmp/pip-install-elc4qdig/xgboost/setup.py", line 110, in build
        subprocess.check_call(cmake_cmd, cwd=build_dir)
      File "/home/wugaosheng/anaconda3/lib/python3.7/subprocess.py", line 341, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'xgboost', '-GUnix Makefiles', '-DUSE_OPENMP=1', '-DUSE_CUDA=0', '-DUSE_NCCL=0', '-DBUILD_WITH_SHARED_NCCL=0', '-DHIDE_CXX_SYMBOLS=1', '-DUSE_HDFS=0', '-DUSE_AZURE=0', '-DUSE_S3=0', '-DPLUGIN_LZ4=0', '-DPLUGIN_DENSE_PARSER=0']' returned non-zero exit status 1.

    ----------------------------------------
Command "/home/wugaosheng/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-elc4qdig/xgboost/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-v6ltzbvr/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-elc4qdig/xgboost/

解决方法

sudo apt remove --purge cmake
hash -r
sudo snap install cmake --classic
cmake --version
pip install xgboost

更新一下cmake就行了哈。

我的日志输出为:

wugaosheng@s206:~/tianchi_job_match/src$ cmake --version
cmake version 3.17.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
wugaosheng@s206:~/tianchi_job_match/src$ pip install xgboost
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting xgboost
  Downloading http://mirrors.aliyun.com/pypi/packages/aa/08/779aaa15de09590fad94cf533e3cc94b967d71b0daddaa2180685712be28/xgboost-1.1.1.tar.gz (731kB)
    100% |████████████████████████████████| 737kB 2.3MB/s
Requirement already satisfied: numpy in /home/wugaosheng/anaconda3/lib/python3.7/site-packages (from xgboost) (1.15.4)
Requirement already satisfied: scipy in /home/wugaosheng/anaconda3/lib/python3.7/site-packages (from xgboost) (1.1.0)
Building wheels for collected packages: xgboost
  Running setup.py bdist_wheel for xgboost ... done
  Stored in directory: /home/wugaosheng/.cache/pip/wheels/e8/28/d4/db7f1dda731e5e14f4349e2c9dcd426a1b83720adae96c3afb
Successfully built xgboost
Installing collected packages: xgboost
Successfully installed xgboost-1.1.1

你可能感兴趣的:(linux)