Unable to pip install old version of scikit-learn

huangapple go评论105阅读模式
英文:

Unable to pip install old version of scikit-learn

问题

我需要使用 scikit-learn==0.23.1(或更旧版本)以使我的项目与 AWS Lambda 层兼容。

此帖子所建议,我尝试运行 pip3 install scikit-learn==0.23.1,但没有成功。

然后,我找到了一个问题,建议运行 pip3 install -U scikit-learn==0.23.1 --no-cache-dir,但这也没有成功。

我正在使用 M1 MacBook Air 上的 Python 3.11.1。以下是运行 pip3 install scikit-learn==0.23.1 时的错误日志:

  1. (错误日志太长,无法完全翻译,请参考原始错误日志以获取更多详细信息)

有关如何成功安装 scikit-learn 0.23.1 版本的任何想法吗?

英文:

I need to use scikit-learn==0.23.1 (or older) to make my project compatible with an AWS Lambda layer.

As suggested by this post, I tried pip3 install scikit-learn==0.23.1, but it did not work.

I then found an issue that suggested pip3 install -U scikit-learn==0.23.1 --no-cache-dir, but it did not work either.

I am using Python 3.11.1 on an M1 MacBook Air. These are the error logs from running pip3 install scikit-learn==0.23.1:

  1. Collecting scikit-learn==0.23.1
  2. Using cached scikit-learn-0.23.1.tar.gz (7.2 MB)
  3. Installing build dependencies ... error
  4. error: subprocess-exited-with-error
  5. × pip subprocess to install build dependencies did not run successfully.
  6. exit code: 1
  7. ╰─> [107 lines of output]
  8. Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX" and platform_python_implementation == "CPython"' don't match your environment
  9. Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX" and platform_python_implementation != "CPython"' don't match your environment
  10. Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment
  11. Ignoring numpy: markers 'python_version == "3.6" and platform_system == "AIX"' don't match your environment
  12. Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment
  13. Ignoring numpy: markers 'python_version >= "3.8" and platform_system == "AIX"' don't match your environment
  14. Collecting setuptools
  15. Using cached setuptools-67.2.0-py3-none-any.whl (1.1 MB)
  16. Collecting wheel
  17. Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
  18. Collecting Cython>=0.28.5
  19. Using cached Cython-0.29.33-py2.py3-none-any.whl (987 kB)
  20. Collecting numpy==1.17.3
  21. Using cached numpy-1.17.3.zip (6.4 MB)
  22. Preparing metadata (setup.py): started
  23. Preparing metadata (setup.py): finished with status 'done'
  24. Collecting scipy>=0.19.1
  25. Using cached scipy-1.10.0-cp311-cp311-macosx_12_0_arm64.whl (28.7 MB)
  26. Using cached scipy-1.9.3-cp311-cp311-macosx_12_0_arm64.whl (28.4 MB)
  27. Using cached scipy-1.9.2-cp311-cp311-macosx_12_0_arm64.whl (28.4 MB)
  28. Using cached scipy-1.9.1.tar.gz (42.0 MB)
  29. Installing build dependencies: started
  30. Installing build dependencies: finished with status 'done'
  31. Getting requirements to build wheel: started
  32. Getting requirements to build wheel: finished with status 'error'
  33. error: subprocess-exited-with-error
  34. × Getting requirements to build wheel did not run successfully.
  35. exit code: 1
  36. ╰─> [67 lines of output]
  37. The Meson build system
  38. Version: 0.62.2
  39. Source dir: /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28
  40. Build dir: /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-7pg6lokl/build
  41. Build type: native build
  42. Project name: SciPy
  43. Project version: 1.9.1
  44. C compiler for the host machine: cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
  45. C linker for the host machine: cc ld64 820.1
  46. C++ compiler for the host machine: c++ (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
  47. C++ linker for the host machine: c++ ld64 820.1
  48. Host machine cpu family: aarch64
  49. Host machine cpu: arm64
  50. Compiler for C supports arguments -Wno-unused-but-set-variable: YES
  51. Library m found: YES
  52. ../../meson.build:41:0: ERROR: Unknown compiler(s): [['gfortran'], ['flang'], ['nvfortran'], ['pgfortran'], ['ifort'], ['g95']]
  53. The following exception(s) were encountered:
  54. Running "gfortran --version" gave "[Errno 2] No such file or directory: 'gfortran'"
  55. Running "gfortran -V" gave "[Errno 2] No such file or directory: 'gfortran'"
  56. Running "flang --version" gave "[Errno 2] No such file or directory: 'flang'"
  57. Running "flang -V" gave "[Errno 2] No such file or directory: 'flang'"
  58. Running "nvfortran --version" gave "[Errno 2] No such file or directory: 'nvfortran'"
  59. Running "nvfortran -V" gave "[Errno 2] No such file or directory: 'nvfortran'"
  60. Running "pgfortran --version" gave "[Errno 2] No such file or directory: 'pgfortran'"
  61. Running "pgfortran -V" gave "[Errno 2] No such file or directory: 'pgfortran'"
  62. Running "ifort --version" gave "[Errno 2] No such file or directory: 'ifort'"
  63. Running "ifort -V" gave "[Errno 2] No such file or directory: 'ifort'"
  64. Running "g95 --version" gave "[Errno 2] No such file or directory: 'g95'"
  65. Running "g95 -V" gave "[Errno 2] No such file or directory: 'g95'"
  66. A full log can be found at /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-7pg6lokl/build/meson-logs/meson-log.txt
  67. + meson setup --native-file=/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=/Library/Frameworks/Python.framework/Versions/3.11 /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28 /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-7pg6lokl/build
  68. Traceback (most recent call last):
  69. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
  70. main()
  71. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
  72. json_out['return_val'] = hook(**hook_input['kwargs'])
  73. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  74. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
  75. return hook(config_settings)
  76. ^^^^^^^^^^^^^^^^^^^^^
  77. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 969, in get_requires_for_build_wheel
  78. with _project(config_settings) as project:
  79. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
  80. return next(self.gen)
  81. ^^^^^^^^^^^^^^
  82. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 948, in _project
  83. with Project.with_temp_working_dir(
  84. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
  85. return next(self.gen)
  86. ^^^^^^^^^^^^^^
  87. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 777, in with_temp_working_dir
  88. yield cls(source_dir, tmpdir, build_dir)
  89. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  90. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 682, in __init__
  91. self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
  92. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 713, in _configure
  93. self._meson(
  94. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 696, in _meson
  95. return self._proc('meson', *args)
  96. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  97. File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 691, in _proc
  98. subprocess.check_call(list(args))
  99. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 413, in check_call
  100. raise CalledProcessError(retcode, cmd)
  101. subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=/Library/Frameworks/Python.framework/Versions/3.11', '/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28', '/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-7pg6lokl/build']' returned non-zero exit status 1.
  102. [end of output]
  103. note: This error originates from a subprocess, and is likely not a problem with pip.
  104. error: subprocess-exited-with-error
  105. × Getting requirements to build wheel did not run successfully.
  106. exit code: 1
  107. ╰─> See above for output.
  108. note: This error originates from a subprocess, and is likely not a problem with pip.
  109. [end of output]
  110. note: This error originates from a subprocess, and is likely not a problem with pip.
  111. error: subprocess-exited-with-error
  112. × pip subprocess to install build dependencies did not run successfully.
  113. exit code: 1
  114. ╰─> See above for output.
  115. note: This error originates from a subprocess, and is likely not a problem with pip.

Any ideas on how to successfully install version 0.23.1 of scikit-learn?

答案1

得分: 2

sklearn==0.23.1 不支持 Python==3.11 的分发包,仅支持 3.6、3.7 和 3.8,所以您需要从源代码安装,但您需要一些二进制文件,如 gfortran 等。

要在 M1 上安装,可以使用 miniforge

> 最近引入的 macos/arm64 平台(有时也称为 macos/aarch64)需要开源社区升级构建配置和自动化以正确支持它。
>在撰写本文时(2021 年 1 月),在此硬件上获取 scikit-learn 的可工作安装的唯一方法是从 conda-forge 分发中安装 scikit-learn 及其依赖项,例如使用 miniforge 安装程序:

https://scikit-learn.org/stable/install.html#installing-on-apple-silicon-m1-hardware

英文:

sklearn==0.23.1 has not distribution package for Python==3.11, only for 3.6, 3.7 and 3.8 so you have to install from source but your need some binaries like gfortran, etc.

To installing on M1, use miniforge:

> The recently introduced macos/arm64 platform (sometimes also known as macos/aarch64) requires the open source community to upgrade the build configuration and automation to properly support it.
>At the time of writing (January 2021), the only way to get a working installation of scikit-learn on this hardware is to install scikit-learn and its dependencies from the conda-forge distribution, for instance using the miniforge installers:

https://scikit-learn.org/stable/install.html#installing-on-apple-silicon-m1-hardware

huangapple
  • 本文由 发表于 2023年2月14日 03:22:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440379.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定