Unable to pip install old version of scikit-learn

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

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 时的错误日志:

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

有关如何成功安装 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:

Collecting scikit-learn==0.23.1
Using cached scikit-learn-0.23.1.tar.gz (7.2 MB)
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [107 lines of output]
Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX" and platform_python_implementation == "CPython"' don't match your environment
Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX" and platform_python_implementation != "CPython"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.6" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version >= "3.8" and platform_system == "AIX"' don't match your environment
Collecting setuptools
Using cached setuptools-67.2.0-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
Collecting Cython>=0.28.5
Using cached Cython-0.29.33-py2.py3-none-any.whl (987 kB)
Collecting numpy==1.17.3
Using cached numpy-1.17.3.zip (6.4 MB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting scipy>=0.19.1
Using cached scipy-1.10.0-cp311-cp311-macosx_12_0_arm64.whl (28.7 MB)
Using cached scipy-1.9.3-cp311-cp311-macosx_12_0_arm64.whl (28.4 MB)
Using cached scipy-1.9.2-cp311-cp311-macosx_12_0_arm64.whl (28.4 MB)
Using cached scipy-1.9.1.tar.gz (42.0 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
╰─> [67 lines of output]
The Meson build system
Version: 0.62.2
Source dir: /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28
Build dir: /private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-install-txosa8qz/scipy_734bcce5e1d549fab1cee5a52c8d7f28/.mesonpy-7pg6lokl/build
Build type: native build
Project name: SciPy
Project version: 1.9.1
C compiler for the host machine: cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
C linker for the host machine: cc ld64 820.1
C++ compiler for the host machine: c++ (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
C++ linker for the host machine: c++ ld64 820.1
Host machine cpu family: aarch64
Host machine cpu: arm64
Compiler for C supports arguments -Wno-unused-but-set-variable: YES
Library m found: YES
../../meson.build:41:0: ERROR: Unknown compiler(s): [['gfortran'], ['flang'], ['nvfortran'], ['pgfortran'], ['ifort'], ['g95']]
The following exception(s) were encountered:
Running "gfortran --version" gave "[Errno 2] No such file or directory: 'gfortran'"
Running "gfortran -V" gave "[Errno 2] No such file or directory: 'gfortran'"
Running "flang --version" gave "[Errno 2] No such file or directory: 'flang'"
Running "flang -V" gave "[Errno 2] No such file or directory: 'flang'"
Running "nvfortran --version" gave "[Errno 2] No such file or directory: 'nvfortran'"
Running "nvfortran -V" gave "[Errno 2] No such file or directory: 'nvfortran'"
Running "pgfortran --version" gave "[Errno 2] No such file or directory: 'pgfortran'"
Running "pgfortran -V" gave "[Errno 2] No such file or directory: 'pgfortran'"
Running "ifort --version" gave "[Errno 2] No such file or directory: 'ifort'"
Running "ifort -V" gave "[Errno 2] No such file or directory: 'ifort'"
Running "g95 --version" gave "[Errno 2] No such file or directory: 'g95'"
Running "g95 -V" gave "[Errno 2] No such file or directory: 'g95'"
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
+ 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
Traceback (most recent call last):
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>
main()
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
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
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
with _project(config_settings) as project:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 948, in _project
with Project.with_temp_working_dir(
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
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
yield cls(source_dir, tmpdir, build_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 682, in __init__
self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 713, in _configure
self._meson(
File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 696, in _meson
return self._proc('meson', *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/c2/v1x2pn511b79mxpbdj208p780000gn/T/pip-build-env-u2xs3lnb/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 691, in _proc
subprocess.check_call(list(args))
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
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.
[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.

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:

确定