Python安装LLVMLite报错及解决方案

问题背景

pip install llvmlite报错:

Building wheels for collected packages: llvmlite
  Building wheel for llvmlite (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/zhanghm/.virtualenvs/python27/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-M1772f/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-M1772f/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/pip-wheel-Vve0nB
       cwd: /tmp/pip-install-M1772f/llvmlite/
  Complete output (11 lines):
  running bdist_wheel
  /home/zhanghm/.virtualenvs/python27/bin/python /tmp/pip-install-M1772f/llvmlite/ffi/build.py
  LLVM version... Traceback (most recent call last):
    File "/tmp/pip-install-M1772f/llvmlite/ffi/build.py", line 168, in <module>
      main()
    File "/tmp/pip-install-M1772f/llvmlite/ffi/build.py", line 158, in main
      main_posix('linux', '.so')
    File "/tmp/pip-install-M1772f/llvmlite/ffi/build.py", line 109, in main_posix
      "to the path for llvm-config" % (llvm_config,))
  RuntimeError: llvm-config failed executing, please point LLVM_CONFIG to the path for llvm-config
  error: command '/home/zhanghm/.virtualenvs/python27/bin/python' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for llvmlite
  Running setup.py clean for llvmlite
Failed to build llvmlite
DEPRECATION: Could not build wheels for llvmlite which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.
Installing collected packages: llvmlite
    Running setup.py install for llvmlite ... error
    ERROR: Command errored out with exit status 1:
     command: /home/zhanghm/.virtualenvs/python27/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-M1772f/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-M1772f/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-record-uAOG6M/install-record.txt --single-version-externally-managed --compile --install-headers /home/zhanghm/.virtualenvs/python27/include/site/python2.7/llvmlite
         cwd: /tmp/pip-install-M1772f/llvmlite/
    Complete output (14 lines):
    running install
    running build
    got version from file /tmp/pip-install-M1772f/llvmlite/llvmlite/_version.py {'version': '0.32.0', 'full': '26059d238f4ba23dff74703dd27168591d889edd'}
    running build_ext
    /home/zhanghm/.virtualenvs/python27/bin/python /tmp/pip-install-M1772f/llvmlite/ffi/build.py
    LLVM version... Traceback (most recent call last):
      File "/tmp/pip-install-M1772f/llvmlite/ffi/build.py", line 168, in <module>
        main()
      File "/tmp/pip-install-M1772f/llvmlite/ffi/build.py", line 158, in main
        main_posix('linux', '.so')
      File "/tmp/pip-install-M1772f/llvmlite/ffi/build.py", line 109, in main_posix
        "to the path for llvm-config" % (llvm_config,))
    RuntimeError: llvm-config failed executing, please point LLVM_CONFIG to the path for llvm-config
    error: command '/home/zhanghm/.virtualenvs/python27/bin/python' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/zhanghm/.virtualenvs/python27/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-M1772f/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-M1772f/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-record-uAOG6M/install-record.txt --single-version-externally-managed --compile --install-headers /home/zhanghm/.virtualenvs/python27/include/site/python2.7/llvmlite Check the logs for full command output

解决方案

sudo apt-get install llvm-8
pip install numba==0.45.1 llvmlite==0.30.0

我最终是通过这个方法解决的,大家可以尝试下。

### TBB库报错解决方案 当遇到TBB库相关的报错问题时,可以按照以下方法逐一排查并解决问题: #### 1. 查找依赖项 如果安装MKL或其他软件包时出现问题,可能是因为某些依赖项未被正确处理。例如,在安装过程中可能会涉及`llvmlite`等依赖项[^1]。因此,建议先确认是否存在此类依赖关系。 可以通过以下命令查找相关依赖项: ```bash pip show llvmlite ``` 此操作可以帮助定位是否有残留的旧版本或冲突的组件。 --- #### 2. 删除冲突文件 对于部分无法正常卸载的情况,可以直接手动删除对应的文件夹。通常这些文件位于Python站点包目录下。以下是具体路径示例(基于Linux系统): ```plaintext /usr/local/lib/python3.x/site-packages/tbb/ ``` 或者Windows下的对应位置: ```plaintext C:\Users\<用户名>\AppData\Local\Programs\Python\Python3x\Lib\site-packages\tbb\ ``` 执行删除前需确保已关闭所有运行中的Python进程,并备份重要数据以防误删。 --- #### 3. 卸载TBB及相关模块 尝试通过标准工具完成清理工作。例如使用`conda`环境管理器来移除指定包及其关联项目: ```bash conda remove tbb mkl ``` 若是纯Pip环境下,则可采用强制模式进行操作(注意风险评估后再决定是否启用): ```bash pip uninstall tbb --yes ``` 针对特殊场景如上述提到的Scipy安装失败情形[^2],还需额外关注其底层实现细节以及历史遗留影响因素。 --- #### 4. 重置配置与重新安装目标程序 最后一步便是恢复初始状态之后再试一次新的部署流程。以Intel MKL为例,官方文档推荐的方式如下所示: ```bash pip install intel-mkl-service ``` 与此同时也要记得调整好编译参数设置以便适配不同操作系统平台特性需求[^3]。 --- ### 总结 综上所述,面对因TBB引起的各类异常状况可以从以上四个方面入手加以应对。每步之间环环相扣缺一不可,只有严格按照顺序依次推进才能达到预期效果。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值