Dockerfile因numba安装失败而出现llvm-config错误

时间:2019-10-12 10:49:23

标签: docker llvm numba pypy

我的使用pypy的Dockerfile失败,出现FileNotFoundError:[错误2]没有这样的文件或目录:安装llvmlite时出现“ llvm-config”,它是numba的依赖项,在我的要求中列出。

我试图遵循并更新此处的说明 Python numba / llvmlite on Debian 8 - i can't build llvmlite

我的错误更详细:

Building wheels for collected packages: llvmlite
Building wheel for llvmlite (setup.py): started
Building wheel for llvmlite (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
 command: /usr/local/bin/pypy3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ux49fegr/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ux49fegr/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-8s6wwump --python-tag pp371
   cwd: /tmp/pip-install-ux49fegr/llvmlite/
Complete output (26 lines):
running bdist_wheel
/usr/local/bin/pypy3 /tmp/pip-install-ux49fegr/llvmlite/ffi/build.py
LLVM version... Traceback (most recent call last):
  File "/tmp/pip-install-ux49fegr/llvmlite/ffi/build.py", line 105, in main_posix
    out = subprocess.check_output([llvm_config, '--version'])
  File "/usr/local/lib-python/3/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/local/lib-python/3/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib-python/3/subprocess.py", line 722, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib-python/3/subprocess.py", line 1354, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'

我不希望安装conda这么重。有没有办法为pypy实现numba安装?

FROM pypy:3.6-slim-stretch

RUN apt-get update && apt-get install -y gnupg wget software-properties-common
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 15CF4D18AF4F7421
RUN apt-add-repository "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-6.0 main"
RUN apt-get update
RUN apt-get -y install cython python-llvm build-essential libedit-dev
RUN apt-get -y install libllvm6.0 llvm-6.0-dev llvm-dev

RUN pip install enum34
ENV LLVM_CONFIG=/usr/lib/llvm-6.0-dev/bin/llvm-config pip install llvmlite
ENV LLVM_CONFIG=/usr/lib/llvm-6.0-dev/bin/llvm-config pip install numba
# ENV LD_LIBRARY_PATH /usr/lib/llvm-6.0-dev/lib/

#... other stuff

RUN apt-get clean && apt-get -y update
RUN apt-get -y install python3-dev \
    && apt-get -y install build-essential

# Add requirements
COPY requirements.txt /tmp/

# Install sphinx first as it does not work inside requirements
RUN pip install -U pip && pip install -U sphinx && pip install numpy && pip install cython &&  \
  pip install -r /tmp/requirements.txt

我希望在pypy上使用numba干净构建docker映像

6 个答案:

答案 0 :(得分:6)

解决方法如果该错误在4月17日之后出现(他们发布了新版本,请参见history)。 解决方法是尝试安装以前的版本

library(data.table)
y[, num := as.numeric(sub(".*rating[^0-9]*(\\d+)\\b.*", "\\1",
         status, ignore.case = TRUE))]
y
#                      status num
#1: client rating 01 approved   1
#2:   John Rating: 2 reproved   2
#3:          Customer rating9   9

答案 1 :(得分:1)

“真实”的解决方案是鼓励llvmlite和/或numba释放出一个pypy轮子。但是对于眼前的问题...

至少由于apt-file,您会以某种方式丢失llvm安装:

$ apt-file find llvm-config |grep llvm-6
llvm-6.0: /usr/bin/llvm-config-6.0
llvm-6.0: /usr/lib/llvm-6.0/bin/llvm-config
llvm-6.0: /usr/share/man/man1/llvm-config-6.0.1.gz

答案 2 :(得分:1)

这为我修复了它-

RUN echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" >> /etc/apt/sources.list
RUN echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" >> /etc/apt/sources.list

RUN apt-get install -y --no-install-recommends libedit-dev build-essential
RUN apt-get install -y --no-install-recommends  llvm-8 llvm-8-dev

RUN LLVM_CONFIG=/usr/bin/llvm-config-8 pip3 install enum34 llvmlite numba

使用版本8,因为最新的llvm版本出错-

RuntimeError: Building llvmlite requires LLVM 7.0.x, 7.1.x or 8.0.x, got '3.7.1'

参考-https://apt.llvm.org/

答案 3 :(得分:1)

目前 numba won't install on python 3.9

我将我的基本 docker 映像从 python:3.9-slim 更改为 python:3.8-slim,然后 pip install numba 成功

答案 4 :(得分:0)

对于在 macOS 上的 Python 3.9 上安装 numba,以下工作:

# install llvm using MacPorts
sudo port install llvm-10
sudo port install llvm_select
sudo port select --set llvm mp-llvm-10
# set environment variable used when building `llvmlite`
export LLVM_CONFIG=/opt/local/bin/llvm-config

# clone, build, and install `llvmlite`
# http://llvmlite.pydata.org/en/latest/admin-guide/install.html#compiling-llvmlite
git clone git@github.com:numba/llvmlite.git
cd llvmlite
python setup.py build
python runtests.py
python setup.py install
cd ..

# clone, build, and install `numba`
# https://numba.readthedocs.io/en/stable/user/installing.html#installing-from-source
git clone git@github.com:numba/numba.git
cd numba
export PATH=/usr/bin/:$PATH  # use clang, same as used for building Python 3.9
pip install -v .
cd ..

以上为:

  • llvmlite 在提交 334411cf638c8e06ba19bfda16b07dd64e9dac3c 和
  • numba 在提交 ca8132ba5e43fc3f79767046ed55217aeeabb35e 时。

答案 5 :(得分:0)

根据https://askubuntu.com/questions/1286131/how-do-i-install-llvm-10-on-ubuntu-18-04 我在 Dockerfile 中添加了这些行

RUN apt-get -y install llvm-10*

RUN rm -f  /usr/bin/llvm-config

RUN ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config

它有效(安装了llvmlite

相关问题