我正在尝试在自定义Docker映像中安装Pylint,该映像基于official Python image的Alpine Linux发行版。我尝试使用以下Dockerfile:
FROM python:3.4-alpine
RUN apk add --update pylint
<<这失败了
Step 2/2 : RUN apk add --update pylint
---> Running in 34949003816d
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
pylint (missing):
required by: world[pylint]
The command '/bin/sh -c apk add --update pylint' returned a non-zero code: 1
此外,我试过
FROM python:3.4-alpine
RUN pip3 install pylint
<<这失败了
Step 2/2 : RUN pip3 install pylint
---> Running in b044e3347d26
Collecting pylint
Downloading pylint-1.7.1-py2.py3-none-any.whl (641kB)
Collecting mccabe (from pylint)
Downloading mccabe-0.6.1-py2.py3-none-any.whl
Collecting isort>=4.2.5 (from pylint)
Downloading isort-4.2.5-py2.py3-none-any.whl (40kB)
Collecting six (from pylint)
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting astroid>=1.5.1 (from pylint)
Downloading astroid-1.5.2-py2.py3-none-any.whl (269kB)
Collecting wrapt (from astroid>=1.5.1->pylint)
Downloading wrapt-1.10.10.tar.gz
Collecting lazy-object-proxy (from astroid>=1.5.1->pylint)
Downloading lazy-object-proxy-1.2.2.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/lazy_object_proxy.egg-info
writing dependency_links to pip-egg-info/lazy_object_proxy.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/lazy_object_proxy.egg-info/top_level.txt
writing pip-egg-info/lazy_object_proxy.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/lazy_object_proxy.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/lazy_object_proxy.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
error: [Errno 2] No such file or directory: 'examples'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1wq1n3ss/lazy-object-proxy/
The command '/bin/sh -c pip3 install pylint' returned a non-zero code: 1
最后,我尝试使用以下Dockerfile从源代码构建Pylint:
FROM python:3.4-alpine
RUN apk add --update openssl
RUN wget https://github.com/PyCQA/pylint/archive/master.zip
RUN unzip master.zip
RUN cd pylint-master && python3 setup.py install
<<这现在失败了
Step 1/5 : FROM python:3.4-alpine
---> 9ac5db25a0ca
Step 2/5 : RUN apk add --update openssl
---> Using cache
---> d9f61f983819
Step 3/5 : RUN wget https://github.com/PyCQA/pylint/archive/master.zip
---> Using cache
---> 2a536c150b22
Step 4/5 : RUN unzip master.zip
---> Using cache
---> e160d601a015
Step 5/5 : RUN cd pylint-master && python3 setup.py install
---> Running in d2a20f20ff12
(...)
Searching for lazy_object_proxy
Reading https://pypi.python.org/simple/lazy_object_proxy/
Downloading https://pypi.python.org/packages/65/63/b6061968b0f3c7c52887456dfccbd07bec2303296911757d8c1cc228afe6/lazy-object-proxy-1.2.2.tar.gz#md5=841b5592bc12c6ef7e48ed1d7a5f9066
Best match: lazy-object-proxy 1.2.2
Processing lazy-object-proxy-1.2.2.tar.gz
Writing /tmp/easy_install-mxtkzpjj/lazy-object-proxy-1.2.2/setup.cfg
Running lazy-object-proxy-1.2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mxtkzpjj/lazy-object-proxy-1.2.2/egg-dist-tmp-f6oeoyxl
error: Setup script exited with error: [Errno 2] No such file or directory: 'examples'
The command '/bin/sh -c cd pylint-master && python3 setup.py install' returned a non-zero code: 1
知道如何安装Pylint吗?
答案 0 :(得分:3)
看起来缺少setuptools
的最新版本。将其添加到Dockerfile后,安装pip
的{{1}}方式就可以了。
pylint
答案 1 :(得分:1)
...以及使pylint在带有Alpine容器的Python 3.7上运行:
FROM python:3.7-alpine
RUN apk update
RUN apk add build-base
RUN pip3 install -U pylint