安装scikit时出错向pip学习

问题描述 投票:0回答:2

我一直在尝试通过命令安装 scikit learn

pip install scikit-learn
,但它向我显示了下面给出的错误。

PS:

  • Python版本3.8.5
  • 点子版本22.3

显示错误:

Collecting scikit-learn
  Using cached scikit-learn-1.1.3.tar.gz (7.0 MB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [96 lines of output]

 Ignoring numpy: markers 'python_version == "3.10" and platform_system == "Windows" and platform_python_implementation != "PyPy"' don't match your environment
      Collecting setuptools<60.0
        Using cached setuptools-59.8.0-py3-none-any.whl (952 kB)
      Collecting wheel
        Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
      Collecting Cython>=0.28.5
        Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
      Collecting oldest-supported-numpy
        Using cached oldest_supported_numpy-2022.8.16-py3-none-any.whl (3.9 kB)
      Collecting scipy>=1.3.2
        Using cached scipy-1.9.3.tar.gz (42.1 MB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'error'
        error: subprocess-exited-with-error

        Getting requirements to build wheel did not run successfully.
        exit code: 1

        [64 lines of output]
        The Meson build system
        Version: 0.63.3
        Source dir: C:\Users\manju\AppData\Local\Temp\pip-install-1t0wentg\scipy_8ed1046c49a04dd98aabab84e6319b67
        Build dir: C:\Users\manju\AppData\Local\Temp\pip-install-1t0wentg\scipy_8ed1046c49a04dd98aabab84e6319b67\.mesonpy-nddxhmy3\build
        Build type: native build
        Project name: SciPy
        Project version: 1.9.3
        C compiler for the host machine: gcc (gcc 9.2.0 "gcc (MinGW.org GCC Build-2) 9.2.0")
        C linker for the host machine: gcc ld.bfd 2.32
        C++ compiler for the host machine: c++ (gcc 9.2.0 "c++ (MinGW.org GCC Build-2) 9.2.0")
        C++ linker for the host machine: c++ ld.bfd 2.32
        Host machine cpu family: x86
        Host machine cpu: x86
        Compiler for C supports arguments -Wno-unused-but-set-variable: YES
        Compiler for C supports arguments -Wno-unused-but-set-variable: YES (cached)
        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
        Compiler for C supports arguments -Wno-incompatible-pointer-types: YES
        Library m found: YES

        ..\..\meson.build:57:0: ERROR: Unknown compiler(s): [['ifort'], ['gfortran'], ['flang'], ['pgfortran'], ['g95']]
        The following exception(s) were encountered:
        Running `ifort --version` gave "[WinError 2] The system cannot find the file specified"
        Running `ifort -V` gave "[WinError 2] The system cannot find the file specified"
        Running `gfortran --version` gave "[WinError 2] The system cannot find the file specified"
        Running `gfortran -V` gave "[WinError 2] The system cannot find the file specified"
        Running `flang --version` gave "[WinError 2] The system cannot find the file specified"
        Running `flang -V` gave "[WinError 2] The system cannot find the file specified"
        Running `pgfortran --version` gave "[WinError 2] The system cannot find the file specified"
        Running `pgfortran -V` gave "[WinError 2] The system cannot find the file specified"
        Running `g95 --version` gave "[WinError 2] The system cannot find the file specified"
        Running `g95 -V` gave "[WinError 2] The system cannot find the file specified"

        A full log can be found at C:\Users\manju\AppData\Local\Temp\pip-install-1t0wentg\scipy_8ed1046c49a04dd98aabab84e6319b67\.mesonpy-nddxhmy3\build\meson-logs\meson-log.txt
        + meson setup --native-file=C:\Users\manju\AppData\Local\Temp\pip-install-1t0wentg\scipy_8ed1046c49a04dd98aabab84e6319b67\.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=c:\users\manju\appdata\local\programs\python\python38-32 C:\Users\manju\AppData\Local\Temp\pip-install-1t0wentg\scipy_8ed1046c49a04dd98aabab84e6319b67 C:\Users\manju\AppData\Local\Temp\pip-install-1t0wentg\scipy_8ed1046c49a04dd98aabab84e6319b67\.mesonpy-nddxhmy3\build
        Traceback (most recent call last):
          File "C:\Users\manju\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>
            main()
          File "C:\Users\manju\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "C:\Users\manju\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 118, in get_requires_for_build_wheel
            return hook(config_settings)
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 969, in get_requires_for_build_wheel
            with _project(config_settings) as project:
          File "c:\users\manju\appdata\local\programs\python\python38-32\lib\contextlib.py", line 113, in __enter__
            return next(self.gen)
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 948, in _project
            with Project.with_temp_working_dir(
          File "c:\users\manju\appdata\local\programs\python\python38-32\lib\contextlib.py", line 113, in __enter__
            return next(self.gen)
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 777, in with_temp_working_dir
            yield cls(source_dir, tmpdir, build_dir)
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 682, in __init__
            self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 713, in _configure
            self._meson(
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 696, in _meson
            return self._proc('meson', *args)
          File "C:\Users\manju\AppData\Local\Temp\pip-build-env-8ril8k9h\overlay\Lib\site-packages\mesonpy\__init__.py", line 691, in _proc
            subprocess.check_call(list(args))
          File "c:\users\manju\appdata\local\programs\python\python38-32\lib\subprocess.py", line 364, in check_call
            raise CalledProcessError(retcode, cmd)
        subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=C:\\Users\\manju\\AppData\\Local\\Temp\\pip-install-1t0wentg\\scipy_8ed1046c49a04dd98aabab84e6319b67\\.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=c:\\users\\manju\\appdata\\local\\programs\\python\\python38-32', 'C:\\Users\\manju\\AppData\\Local\\Temp\\pip-install-1t0wentg\\scipy_8ed1046c49a04dd98aabab84e6319b67', 'C:\\Users\\manju\\AppData\\Local\\Temp\\pip-install-1t0wentg\\scipy_8ed1046c49a04dd98aabab84e6319b67\\.mesonpy-nddxhmy3\\build']' returned non-zero exit status 1.
        [end of output]

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

      Getting requirements to build wheel 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.
      [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.
python installation scikit-learn pip subprocess
2个回答
0
投票

主要问题体现在这部分回溯中:

..\..\meson.build:57:0: ERROR: Unknown compiler(s): [['ifort'], ['gfortran'], ['flang'], ['pgfortran'], ['g95']]

这表示未找到 Fortran 编译器。


这可能是由 32 位版本的 Python 引起的,因为预编译版本的依赖项(

numpy
scipy
)和 Fortran 库并不总是可用。

安装 Anaconda 或 Miniconda 的副本是最直接的解决方案。然后安装 scikit-learn:

conda install -c anaconda scikit-learn

0
投票

gfortran 是 GCC 编译器的一部分。您可以使用 MSYS2 安装它。 (应该添加到 PATH,另外我从 VSbuld_tools 添加 cmake)。

如果你不想造轮子 - 你可以尝试找到(例如here)已经编译的.whl文件,但要小心选择python版本和某些文件版本的依赖关系。

© www.soinside.com 2019 - 2024. All rights reserved.