簡體   English   中英

安裝 scikit 時出錯從 pip 學習

[英]error while installing scikit learn from pip

我一直在嘗試通過命令pip install scikit-learn安裝 scikit learn,但它向我顯示了下面給出的錯誤。

附言:

  • Python 版本 3.8.5
  • pip 版本 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.

主要問題顯示在回溯的這一部分:

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

這表示未找到 Fortran 編譯器。


這可能是由 32 位版本的 Python 引起的,因為依賴項( numpyscipy )和 Fortran 庫的預編譯版本並不總是可用。

安裝Anaconda 或 Miniconda的副本是最直接的解決方案。 然后使用以下命令安裝 scikit-learn:

conda install -c anaconda scikit-learn

gfortran 是 GCC 編譯器的一部分。 您可以使用 MSYS2 安裝它。

如果你不想造輪子 - 你可以嘗試找到(例如在這里)已經編譯的.whl文件,但要小心選擇 python 版本和某些文件版本的依賴性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM