Python pip安装spleeter报错

Python PIP安装spleeter时报错:

C:\Users\Administrator>pip install spleeter
Looking in indexes: https://pypi.org/simple, https://pypi.tuna.tsinghua.edu.cn/simple, https://mirrors.cernet.edu.cn/list/pypi
Collecting spleeter
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/10/0b/1ee10015ae2269c1cd1ae5439ae8d48d8680dd984638b4b787d1e4ce4e6b/spleeter-2.1.0-py3-none-any.whl (50 kB)
Collecting ffmpeg-python==0.2.0 (from spleeter)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d7/0c/56be52741f75bad4dc6555991fabd2e07b432d333da82c11ad701123888a/ffmpeg_python-0.2.0-py3-none-any.whl (25 kB)
Collecting httpx[http2]<0.17.0,>=0.16.1 (from spleeter)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2d/c6/59aa4188e7eddb9e89ec67a51598ca6bfc09f1b38c9b45f7ee45af7a4df4/httpx-0.16.1-py3-none-any.whl (65 kB)
Collecting librosa==0.8.0 (from spleeter)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/26/4d/c22d8ca74ca2c13cd4ac430fa353954886104321877b65fa871939e78591/librosa-0.8.0.tar.gz (183 kB)
  Preparing metadata (setup.py) ... done
Collecting norbert==0.2.1 (from spleeter)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/22/85/1e4f09c84d28b5541a4a8eece320902c4d2fa264dfe51f779548396f0fea/norbert-0.2.1-py2.py3-none-any.whl (11 kB)
Collecting numpy<1.19.0,>=1.16.0 (from spleeter)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/01/1b/d3ddcabd5817be02df0e6ee20d64f77ff6d0d97f83b77f65e98c8a651981/numpy-1.18.5.zip (5.4 MB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      Looking in indexes: https://pypi.org/simple, https://pypi.tuna.tsinghua.edu.cn/simple, https://mirrors.cernet.edu.cn/list/pypi, https://pypi.tuna.tsinghua.edu.cn/simple, https://mirrors.cernet.edu.cn/list/pypi
      Collecting setuptools
        Downloading setuptools-67.8.0-py3-none-any.whl (1.1 MB)
           ---------------------------------------- 1.1/1.1 MB 11.9 kB/s eta 0:00:00
      Collecting wheel
        Using cached https://pypi.tuna.tsinghua.edu.cn/packages/61/86/cc8d1ff2ca31a312a25a708c891cf9facbad4eae493b3872638db6785eb5/wheel-0.40.0-py3-none-any.whl (64 kB)
      Collecting Cython>=0.29.14
        Downloading Cython-0.29.35-py2.py3-none-any.whl (988 kB)
           ------------------------------------- 988.4/988.4 kB 12.3 kB/s eta 0:00:00
      Installing collected packages: wheel, setuptools, Cython
      ERROR: Cannot set --home and --prefix together
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

从错误日志可以看出,在安装numpy时出错了,原因是numpy安装有编译依赖,需要先安装Cython和setuptools等,但是安装这些编译依赖时又出错了。
解决方法如下:

  1. 升级pip版本,老版本的pip可能会出现这样的问题。运行:
    python -m pip install --upgrade pip
  2. 安装编译工具和依赖。对于Windows,可以安装Visual Studio Build Tools;对于Mac/Linux,可以安装Xcode Command Line Tools或equivalent。
  3. 安装numpy时指定编译选项:
    pip install numpy --global-option=build_ext --global-option="-I/path/to/include" --global-option="-L/path/to/lib"
    将/path/to/include和/path/to/lib替换为你的编译依赖的include目录和lib目录。
  4. 如果上述方法还不行,可以试试下载numpy wheel包离线安装:
    pip install /path/to/numpy‐1.18.5‐cp38‐cp38‐win_amd64.whl
    将路径和文件名替换为你下载的wheel包。