Centos7 安装sklearn gcc: error: ‘-Qunused-arguments’

本文档详细记录了解决在CentOS7环境下安装Sklearn过程中遇到的各种错误的方法。通过更新pip版本并使用whl安装文件成功安装了Scikit-Learn,并验证了安装的有效性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 在centos7上安装sklearn各种报错

gcc: error: unrecognized command line option ‘-Qunused-arguments’
gcc: error: unrecognized command line option ‘-Qunused-arguments’
gcc: error: unrecognized command line option ‘-Qunused-arguments’

google下应该是pip版本问题,之前安装的pip版本是7.1,现在最新版本都到8.1了

2. 在pipy下载pip whl安装文件

https://pypi.python.org/pypi/pip下载whl安装文件

下载:

[root@slaver3 ~]# wget https://pypi.python.org/packages/9c/32/004ce0852e0a127f07f358b715015763273799bd798956fa930814b60f39/pip-8.1.2-py2.py3-none-any.whl#md5=0570520434c5b600d89ec95393b2650b
--2016-09-05 16:19:48--  https://pypi.python.org/packages/9c/32/004ce0852e0a127f07f358b715015763273799bd798956fa930814b60f39/pip-8.1.2-py2.py3-none-any.whl
Resolving pypi.python.org (pypi.python.org)... 151.101.24.223, 2a04:4e42:6::223
Connecting to pypi.python.org (pypi.python.org)|151.101.24.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1198961 (1.1M) [application/octet-stream]
Saving to: ‘pip-8.1.2-py2.py3-none-any.whl100%[=====================================================>] 1,198,961    667KB/s   in 1.8s

2016-09-05 16:19:50 (667 KB/s) - ‘pip-8.1.2-py2.py3-none-any.whl’ saved [1198961/1198961]

安装

[root@slaver3 ~]# pip install pip-8.1.2-py2.py3-none-any.whl
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing ./pip-8.1.2-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
      Successfully uninstalled pip-7.1.0
Successfully installed pip-8.1.2

3. pip安装sklearn

[root@slaver3 Cython-0.24.1]# pip install sklearn
Collecting sklearn
Collecting scikit-learn (from sklearn)
  Downloading scikit_learn-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl (17.6MB)
    100% |████████████████████████████████| 17.6MB 50kB/s
Installing collected packages: scikit-learn, sklearn
Successfully installed scikit-learn-0.17.1 sklearn-0.0

4. 验证是否安装成功

[root@slaver3 Cython-0.24.1]# ipython
Python 2.7.5 (default, Aug 18 2016, 15:58:25)
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from sklearn.datasets import load_iris

In [2]: iris = load_iris()

In [3]: iris.data
Out[3]:
array([[ 5.1,  3.5,  1.4,  0.2],
       [ 4.9,  3. ,  1.4,  0.2],
       [ 4.7,  3.2,  1.3,  0.2],
       [ 4.6,  3.1,  1.5,  0.2],
       [ 5. ,  3.6,  1.4,  0.2],
......
$ pip3 install PTM-POSE Collecting PTM-POSE Downloading ptm_pose-0.3.0-py3-none-any.whl.metadata (7.6 kB) Collecting pandas==2.2.* (from PTM-POSE) Downloading pandas-2.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (89 kB) Collecting numpy==1.26.* (from PTM-POSE) Downloading numpy-1.26.4.tar.gz (15.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.8/15.8 MB 478.4 kB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Collecting scipy==1.13.* (from PTM-POSE) Downloading scipy-1.13.1.tar.gz (57.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.2/57.2 MB 474.2 kB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [43 lines of output] + meson setup /tmp/pip-install-z8uxbhaj/scipy_2d56e94197b1489098e8f0980667dae9 /tmp/pip-install-z8uxbhaj/scipy_2d56e94197b1489098e8f0980667dae9/.mesonpy-nurt08x2 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pip-install-z8uxbhaj/scipy_2d56e94197b1489098e8f0980667dae9/.mesonpy-nurt08x2/meson-python-native-file.ini The Meson build system Version: 1.8.2 Source dir: /tmp/pip-install-z8uxbhaj/scipy_2d56e94197b1489098e8f0980667dae9 Build dir: /tmp/pip-install-z8uxbhaj/scipy_2d56e94197b1489098e8f0980667dae9/.mesonpy-nurt08x2 Build type: native build Project name: scipy Project version: 1.13.1 C compiler for the host machine: cc (gcc 13.3.0 "cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0") C linker for the host machine: cc ld.bfd 2.42 C++ compiler for the host machine: c++ (gcc 13.3.0 "c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0") C++ linker for the host machine: c++ ld.bfd 2.42 Cython compiler for the host machine: cython (cython 3.0.12) Host machine cpu family: x86_64 Host machine cpu: x86_64 Program python found: YES (/mnt/940660EA0660CEB4/PTM-POSE/myenv/bin/python3) Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1 Run-time dependency python found: YES 3.13 Program cython found: YES (/tmp/pip-build-env-13qjdw3k/overlay/bin/cython) Compiler for C supports arguments -Wno-unused-but-set-variable: YES Compiler for C supports arguments -Wno-unused-function: YES Compiler for C supports arguments -Wno-conversion: YES Compiler for C supports arguments -Wno-misleading-indentation: YES Library m found: YES Fortran compiler for the host machine: gfortran (gcc 13.3.0 "GNU Fortran (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0") Fortran linker for the host machine: gfortran ld.bfd 2.42 Compiler for Fortran supports arguments -Wno-conversion: YES Checking if "-Wl,--version-script" links: YES Program pythran found: YES 0.15.0 0.15.0 (/tmp/pip-build-env-13qjdw3k/overlay/bin/pythran) Found CMake: /usr/bin/cmake (3.28.3) Run-time dependency xsimd found: NO (tried pkgconfig and cmake) Run-time dependency threads found: YES Library npymath found: YES Library npyrandom found: YES pybind11-config found: YES (/tmp/pip-build-env-13qjdw3k/overlay/bin/pybind11-config) 2.12.1 Run-time dependency pybind11 found: YES 2.12.1 Run-time dependency scipy-openblas found: NO (tried pkgconfig) Run-time dependency openblas found: NO (tried pkgconfig and cmake) Run-time dependency openblas found: NO (tried pkgconfig and cmake) ../scipy/meson.build:163:9: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig and cmake A full log can be found at /tmp/pip-install-z8uxbhaj/scipy_2d56e94197b1489098e8f0980667dae9/.mesonpy-nurt08x2/meson-logs/meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
最新发布
07-06
<think>我们正在处理一个关于安装PTM-POSE包时遇到的依赖问题,具体是scipy编译错误,提示Dependency OpenBLAS not found。 用户的问题:pip install PTM-POSE 安装失败,依赖scipy编译错误,提示Dependency OpenBLAS not found。 分析: 1. PTM-POSE包可能依赖于scipy,而scipy在安装时通常需要编译,编译过程中需要OpenBLAS(一个优化的BLAS库)。 2. 错误信息表明在编译scipy时找不到OpenBLAS库。 解决方案: 我们需要确保系统安装了OpenBLAS开发库。因为不同的操作系统安装方式不同,我们需要提供针对不同操作系统的解决方案。 常见操作系统:Linux(Ubuntu/Debian, CentOS/RHEL等),macOS,Windows。 注意:在Windows上,通常使用预编译的二进制包,所以可能不会遇到编译问题。但用户遇到了,可能是由于环境问题或尝试从源码编译。 步骤: 1. 对于Linux系统(以Ubuntu/Debian为例): - 安装OpenBLAS开发包:`sudo apt-get install libopenblas-dev` 2. 对于CentOS/RHEL: - 安装OpenBLAS开发包:`sudo yum install openblas-devel` 或 `sudo dnf install openblas-devel` 3. 对于macOS(使用Homebrew): - 安装OpenBLAS:`brew install openblas` 4. 对于Windows: - 通常,预编译的scipy包应该已经包含了所需的BLAS库。如果遇到编译错误,建议使用预编译的二进制轮子(wheels)来安装scipy,避免编译。 - 可以尝试从https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载预编译的scipy包,然后使用pip安装- 或者,确保安装了Microsoft Visual C++ Build Tools。 此外,如果用户是在类Unix系统上(Linux或macOS),并且已经安装了OpenBLAS,但scipy仍然找不到,可能需要设置环境变量告诉scipy OpenBLAS的位置。 例如,在Linux/macOS上,可以设置: export OPENBLAS=/path/to/openblas (具体路径需要根据安装情况确定) 但是,通常通过系统的包管理器安装后,scipy应该能够自动找到。 另外,也可以考虑使用conda来安装,因为conda可以很好地处理这些依赖。 建议用户尝试使用conda安装: conda install -c conda-forge scipy conda install -c conda-forge ptm-pose # 如果conda-forge有ptm-pose包的话 但是,我们不确定PTM-POSE是否在conda-forge上。如果没有,可以先安装scipy,然后再用pip安装PTM-POSE。 步骤总结: 1. 根据操作系统安装OpenBLAS开发库(Windows除外)。 2. 然后尝试重新安装PTM-POSE,因为安装PTM-POSE时会自动安装其依赖(包括scipy),此时scipy应该能够编译成功。 3. 如果问题仍然存在,可以尝试先单独安装scipy(确保scipy安装成功),再安装PTM-POSE。 对于Windows用户,建议: - 确保安装Microsoft Visual C++ 14.0或更高版本(可以从Visual Studio安装)。 - 或者,使用预编译的scipy轮子。 如果用户已经尝试了上述步骤仍然失败,可以提供更多环境信息(如操作系统、Python版本等)以便进一步排查。 生成相关问题: 1. 如何检查系统中是否安装了OpenBLAS? 2. 在Windows上如何安装Microsoft Visual C++ Build Tools? 3. 如何使用conda安装PTM-POSE? 4. 除了OpenBLAS,scipy的编译还需要哪些依赖? 5. 如何从源码编译scipy? 注意:回答中引用的段落末尾自然地添加引用标识。由于我们目前没有外部引用,所以暂时不添加,但可以提及一些常见参考资源,如Stack Overflow等。 现在,我们按照要求组织回答。</think>### PTM-POSE安装问题:解决Scipy依赖的OpenBLAS编译错误 安装PTM-POSE时出现`Dependency OpenBLAS not found`错误,是由于Scipy编译需要OpenBLAS数学库支持。以下是系统级解决方案: #### 解决方案(按操作系统分类) 1. **Linux系统(Ubuntu/Debian)** 安装OpenBLAS开发包: ```bash sudo apt-get update sudo apt-get install libopenblas-dev gfortran ``` 然后重试安装: ```bash pip install PTM-POSE ``` 2. **CentOS/RHEL系统** ```bash sudo yum install openblas-devel gcc-gfortran ``` 3. **macOS系统** ```bash brew install openblas export OPENBLAS="$(brew --prefix openblas)" pip install --no-binary :all: scipy # 强制源码编译 pip install PTM-POSE ``` 4. **Windows系统** 安装预编译包避免源码编译: ```bash pip install --prefer-binary PTM-POSE ``` 若失败,手动安装SciPy轮子: 访问[SciPy预编译包](https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy)下载对应版本的`.whl`文件,然后: ```bash pip install 下载路径/scipy-xxx.whl pip install PTM-POSE ``` #### 验证安装 ```python import scipy scipy.show_config() # 检查OpenBLAS链接状态 ``` #### 备选方案 若仍失败,使用conda管理环境: ```bash conda create -n ptm_env python=3.9 conda activate ptm_env conda install -c conda-forge scipy openblas pip install PTM-POSE ``` > **关键原理**:Scipy的矩阵运算依赖BLAS/LAPACK实现,OpenBLAS是开源高性能实现。编译时需头文件(`*.h`)和静态库(`libopenblas.a`),包管理器提供这些开发文件[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值