如何在 Ubuntu 18.04 上安装 llvm-10?

Cod*_*123 5 python software-installation

有一些较早的问题,最值得注意的是 this,但它们对我没有帮助。我试图安装LLVM版本10(或9),因为它是一个依赖pyod Python包。尝试安装时,出现此错误:

(.venv) user@desktop:/media/Projects/outliers$ pip install llvmlite
Collecting llvmlite
  Using cached https://files.pythonhosted.org/packages/0b/96/07bfa93a103fb9e3e9ae7f9f7c6687ae714aee66b6f3000da3fad71e0aa2/llvmlite-0.34.0.tar.gz
Building wheels for collected packages: llvmlite
  Running setup.py bdist_wheel for llvmlite ... error
  Complete output from command /media/Projects/outliers/.venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a4jzbt70/llvmlite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpzu8welrdpip-wheel- --python-tag cp36:
  running bdist_wheel
  /media/Projects/outliers/.venv/bin/python3 /tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py
  LLVM version... 6.0.0
  
  Traceback (most recent call last):
    File "/tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py", line 191, in <module>
      main()
    File "/tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py", line 181, in main
      main_posix('linux', '.so')
    File "/tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py", line 143, in main_posix
      raise RuntimeError(msg)
  RuntimeError: Building llvmlite requires LLVM 10.0.x or 9.0.x, got '6.0.0'. Be sure to set LLVM_CONFIG to the right executable path.
  Read the documentation at http://llvmlite.pydata.org/ for more information about building llvmlite.
  
  error: command '/media/Projects/outliers/.venv/bin/python3' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for llvmlite
  Running setup.py clean for llvmlite
Failed to build llvmlite
Installing collected packages: llvmlite
  Running setup.py install for llvmlite ... error
    Complete output from command /media/Projects/outliers/.venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a4jzbt70/llvmlite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-xelmdsmd-record/install-record.txt --single-version-externally-managed --compile --install-headers /media/Projects/outliers/.venv/include/site/python3.6/llvmlite:
    running install
    running build
    got version from file /tmp/pip-build-a4jzbt70/llvmlite/llvmlite/_version.py {'version': '0.34.0', 'full': 'c5889c9e98c6b19d5d85ebdd982d64a03931f8e2'}
    running build_ext
    /media/Projects/outliers/.venv/bin/python3 /tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py
    LLVM version... 6.0.0
    
    Traceback (most recent call last):
      File "/tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py", line 191, in <module>
        main()
      File "/tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py", line 181, in main
        main_posix('linux', '.so')
      File "/tmp/pip-build-a4jzbt70/llvmlite/ffi/build.py", line 143, in main_posix
        raise RuntimeError(msg)
    RuntimeError: Building llvmlite requires LLVM 10.0.x or 9.0.x, got '6.0.0'. Be sure to set LLVM_CONFIG to the right executable path.
    Read the documentation at http://llvmlite.pydata.org/ for more information about building llvmlite.
    
    error: command '/media/Projects/outliers/.venv/bin/python3' failed with exit status 1
    
    ----------------------------------------
Command "/media/Projects/outliers/.venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a4jzbt70/llvmlite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-xelmdsmd-record/install-record.txt --single-version-externally-managed --compile --install-headers /media/Projects/outliers/.venv/include/site/python3.6/llvmlite" failed with error code 1 in /tmp/pip-build-a4jzbt70/llvmlite/
Run Code Online (Sandbox Code Playgroud)

我相信最重要的一行是:

RuntimeError: Building llvmlite requires LLVM 10.0.x or 9.0.x, got '6.0.0'. Be sure to set LLVM_CONFIG to the right executable path.
Run Code Online (Sandbox Code Playgroud)

如果尝试更新它,它会说 6.X 是最新的:

user@desktop:~$ apt install llvm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
llvm is already the newest version (1:6.0-41~exp5~ubuntu1).
The following packages were automatically installed and are no longer required:
  boinc-client golang-1.10-go golang-1.10-src golang-src libboinc7 libgsoap-2.8.60 libllvm10 libllvm10:i386 libnvidia-cfg1-440 libnvidia-common-435 libnvidia-common-440
  libnvidia-compute-440 libnvidia-decode-440 libnvidia-ifr1-440 libvncserver1 linux-headers-4.15.0-106 linux-headers-4.15.0-106-generic linux-headers-4.15.0-115
  linux-headers-4.15.0-115-generic linux-headers-5.4.0-45-generic linux-hwe-5.4-headers-5.4.0-45 python-fasteners python-monotonic python-pexpect python-ptyprocess
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
Run Code Online (Sandbox Code Playgroud)

我也尝试过 1)使用他们的 apt deb 源(不起作用,添加时没有任何反应,使用时最新版本仍然是 6.X apt upgrade),以及 2)下载他们的文件(没有给出如何安装的说明)。

小智 8

检查如何在此处安装 LLVM https://apt.llvm.org/以检索这样的存档签名:

wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
Run Code Online (Sandbox Code Playgroud)

添加从何处安装的 PPA:

add-apt-repository 'deb http://apt.llvm.org/bionic/   llvm-toolchain-bionic-10  main'
Run Code Online (Sandbox Code Playgroud)

更新包:

sudo apt update
Run Code Online (Sandbox Code Playgroud)

安装默认的 llvm 和 llvm-config:

sudo apt install llvm
Run Code Online (Sandbox Code Playgroud)

安装自定义版本:llvm-10 & llvm-config-10:

sudo apt-get install llvm-10 lldb-10 llvm-10-dev libllvm10 llvm-10-runtime
Run Code Online (Sandbox Code Playgroud)

使用“update-alternatives”为“llvm-config”配置这样的替代方案:

sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-6.0 6
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-10 10
sudo update-alternatives --config llvm-config
Run Code Online (Sandbox Code Playgroud)

. . . 并选择:“1”

选择 小路 优先事项 地位
* 0 /usr/bin/llvm-config-6.0 6 自动模式 0
1 /usr/bin/llvm-config-10 10 自动模式 1

按 <enter> 保留当前选择[*],或键入选择编号:1


Cod*_*123 6

我使用的是 Mint 19.3,但这也适用于 Ubuntu 18.04,这是这个 Mint 版本的基础。

我的解决方案是指定安装时专门使用的版本:

sudo apt-get install llvm-10*
Run Code Online (Sandbox Code Playgroud)

在这里使用 glob 星号的原因是一些相关的包也需要一些东西才能工作,所以仅仅安装基本包是行不通的(至少,当你尝试 pip install 时,pyod不会给你llvm-config: error: component libraries and shared library)。这里提到了这个后续问题和解决方案。

在此之后,您需要更改llvm-config链接,否则它仍然指向 6.X 版本。这是由(从这里)完成的:

sudo -i
cd /usr/bin
rm llvm-config #if it exists already, which probably it does
ln -s llvm-config-10 llvm-config
Run Code Online (Sandbox Code Playgroud)

配置现在指向正确的版本。安装10版本不会更新这个指针。在此之后,我的pip命令起作用了(即pip install llvmlite,之后,pip install pyod)。

  • `sudo apt-get install llvm-10*` 给出无法定位。有什么想法吗? (2认同)