无法在Python 3.10上安装Numba。

4

在运行OS 11.6.1的Mac上,安装了Python 3.10。我卸载了我的机器上的Python 3.9并升级到了版本3.10,安装标准包如pandas、 scipy等都没有问题。但是一个名为epcyom的包需要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。 - Samuel
也许可以尝试从brew.sh安装brew,并运行brew install llvm命令? - Samuel
LLVM没有与pip一起分发 - 请尝试使用Homebrew之类的工具进行安装。 - ades
感谢您的建议。使用Homebrew安装时出现以下消息:错误:`brew link`步骤未成功完成 该公式已构建,但未链接到/usr/local 无法创建符号链接bin/pyi-archive_viewer 目标/usr/local/bin/pyi-archive_viewer 已存在稍后的消息指出:因为macOS已经提供了此软件,并且在并行安装另一个版本可能会引起各种问题。``` - fishbacp
4个回答

8

@JCaesar numpy和numba是完全不同的东西。 - Akmal Soliev
1
你说得很对。我读了一件事情,但理解成了另一件事情。我的错。抱歉。 - DarkKnight
1
@AkmalSoliev 我会尝试你的建议,回到3.9版本看看是否有效。这可能需要一些时间,但我会给你回复并在有效时“接受”。谢谢。 - fishbacp
@fishbacp 3.9成功了吗? - a06e
它必须存在。我现在能够导入它,而且在过去的一年中我没有更改Python版本。 - fishbacp

3

直接摘自llvmlite文档

为什么这会成为一个问题。

如果您使用的是不受支持的架构(即非x86 *)或不支持二进制轮(例如Python alphas)的Python版本,则pip将尝试从sdist构建Numba,然后将尝试从sdist构建llvmlite。这将不可避免地失败,因为llvmlite源分发需要适当的LLVM安装来构建。

如果您使用的是pip<19.0,则manylinux2010轮将无法安装,并且您将陷入第1种情况,即某些不受支持的内容,因此需要从sdist构建。

从历史上看,此问题已表现为以下错误消息,该消息完全引用如下以供参考:

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

解决方法…

如果你使用的 pip 版本小于 19.0,且在 x86* 平台上,则建议更新 pip 版本,这样可以使用 manylinux2010 二进制 wheel。

如果你使用的是不受支持的架构,例如树莓派,请尝试使用 conda。

否则,你可能需要从源代码编译安装,这需要提供一个 LLVM。如果你有可用的 conda,可以使用它来引导安装,并安装一个有效的 llvm/llvmdev 包。关于手动编译的更多信息,请查看下面的“手动编译”部分。特别注意使用 LLVM_CONFIG 环境变量指定 LLVM 安装位置。


1

有人已经指出了numba的LLVM-config问题。根据GitHub链接,我建议降级LLVM,因为GitHub链接说明尚不支持LLVM 9。可能我说的不正确,希望这可以帮到你!


在升级到Python 3.10之前,我创建了一个列表,列出了所有我的软件包及其当前版本。我没有看到LLVM,只有llvmlite 0.36.0。它似乎可以让我想要的软件包epycom正常工作,但我不认为我真正理解LLVM和llvmlite之间的关系。 - fishbacp
1
@fishbacp 有点晚了,但是 llvmlite 包含了 LLVM 的 Python 绑定。 - bfontaine

0
更新llvmlite到"^0.41.0"并降级numpy到">=1.25,<1.26"后,我成功安装了numba"^0.58.0"。
[这是基于@Akmal Soliev发布的github问题 - 我在阅读这篇文章之前碰巧遇到了这些问题。]

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接