【问题标题】:Can't install numba on Python 3.10无法在 Python 3.10 上安装 numba
【发布时间】:2022-01-05 15:28:24
【问题描述】:

运行 OS 11.6.1 的 Mac 上的 Python 3.10

我从我的机器上卸载了 Python 3.9 并升级到了 3.10 版本。安装标准包(如 pandas、scipy 等)没有问题。但是一个包 epycom 需要 numba。

当我输入pip3 install numba 时,我会收到下面的冗长错误消息,其中包含关键字FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'

想知道是否应该卸载 3.10 并返回到 3.9?

Collecting numba
  Using cached numba-0.51.2.tar.gz (2.1 MB)
  Preparing metadata (setup.py) ... done
Collecting llvmlite<0.35,>=0.34.0.dev0
  Using cached llvmlite-0.34.0.tar.gz (107 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.15 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from numba) (1.22.0)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from numba) (58.1.0)
Using legacy 'setup.py install' for numba, since package 'wheel' is not installed.
Using legacy 'setup.py install' for llvmlite, since package 'wheel' is not installed.
Installing collected packages: llvmlite, numba
    Running setup.py install for llvmlite ... error
    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/setup.py'"'"'; __file__='"'"'/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-record-6u_7985j/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.10/include/python3.10/llvmlite
         cwd: /private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/
    Complete output (29 lines):
    running install
    running build
    got version from file /private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/llvmlite/_version.py {'version': '0.34.0', 'full': 'c5889c9e98c6b19d5d85ebdd982d64a03931f8e2'}
    running build_ext
    /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 /private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/ffi/build.py
    LLVM version... Traceback (most recent call last):
      File "/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/ffi/build.py", line 105, in main_posix
        out = subprocess.check_output([llvm_config, '--version'])
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 420, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 501, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 966, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1842, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/ffi/build.py", line 191, in <module>
        main()
      File "/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/ffi/build.py", line 185, in main
        main_posix('osx', '.dylib')
      File "/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/ffi/build.py", line 107, in main_posix
        raise RuntimeError("%s failed executing, please point LLVM_CONFIG "
    RuntimeError: llvm-config failed executing, please point LLVM_CONFIG to the path for llvm-config
    error: command '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/setup.py'"'"'; __file__='"'"'/private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-install-42hw6q4a/llvmlite_a0abee749e71467a998628e47a3a1a24/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6j/xqx91xb15wl81pcnf33255bct7pzn4/T/pip-record-6u_7985j/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.10/include/python3.10/llvmlite Check the logs for full command output.
fishbacp@fishbacpK0ML85 ~ % pip3 install llvm
ERROR: Could not find a version that satisfies the requirement llvm (from versions: none)
ERROR: No matching distribution found for llvm

【问题讨论】:

  • LLVM 没有安装,或者程序找不到 llvm-config。
  • 也许尝试从 brew.sh 安装 brew,然后运行 ​​brew install llvm?
  • llvm 没有与 pip 一起分发 - 尝试使用 homebrew 之类的东西安装它。
  • 感谢您的建议。使用 homebrew 安装导致消息 Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/pyi-archive_viewer Target /usr/local/bin/pyi-archive_viewer already exists 后面的消息指出 llvm is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.

标签: python pip numba


【解决方案1】:

基于 Github 上提交的历史问题,numba 采用新 Python 版本的速度很慢;我的猜测是它目前不支持 Python 3.10。

参考:

https://github.com/numba/llvmlite/issues/621

https://github.com/numba/llvmlite/issues/531

【讨论】:

  • @JCaesar numpy 和 numba 是完全不同的东西
  • 你说的很对。我读了一件事,理解了另一件事。我的错。对不起
  • @AkmalSoliev 我将继续你的观察并回到 3.9 看看它是否有效。这将需要一段时间,但如果需要,我会回复您并“接受”。谢谢。
【解决方案2】:

直接取自llvmlite documentation

这最终会成为一个问题。

如果您使用的是不受支持的架构(即不是 x86*)或二进制轮子不受支持的 Python 版本(例如 Python alphas),那么 pip 将尝试从 sdist 构建 Numba,而后者又会尝试从 sdist 构建 llvmlite。这将不可避免地失败,因为 llvmlite 源代码分发需要适当的 LLVM 安装才能构建。

如果您使用的是 pip

从历史上看,此问题已表现为以下错误消息,此处逐字包含以供将来参考:

FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'

“修复”它的事情……

如果您在 x86* 上使用 pip

如果您使用的是不受支持的架构,例如 Raspberry Pi,请使用 conda(如果有)。

否则:您可能需要从源代码构建,这意味着提供 LLVM。如果你有 conda 可用,你可以使用它来引导安装,并使用一个工作的 llvm/llvmdev 包。在下面的手动构建部分中了解有关从源代码编译的更多信息。并特别注意使用 LLVM_CONFIG 环境变量来指定 LLVM 的安装位置。

【讨论】:

    【解决方案3】:

    有人已经指出了 numba 的 LLVM 配置问题。根据 GitHub 链接,我会尝试降级 LLVM,因为 GitHub 链接指出 LLVM 9 尚不支持。我可能不正确,希望对您有所帮助!

    【讨论】:

    • 在升级到 Python 3.10 之前,我创建了一个包含所有包及其当前版本的列表。我没有看到 LLVM,只有 llvmlite 0.36.0 。它似乎让我想要的包 epycom 工作了我不认为我真的了解 LLVM 和 llvmlite 之间的关系。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 2022-12-12
    • 1970-01-01
    • 2022-07-14
    • 2022-01-20
    • 1970-01-01
    • 2015-05-28
    相关资源
    最近更新 更多