我正在尝试使用Python 3.6环境在Ubuntu 18.04 docker容器中安装cppyy。它在本地(K)ubuntu 18.04安装上运行良好。它失败了,关于没有生成文件的轮子的遗留构建错误。
我已经在Docker容器中更新了g ++,以确保这不是问题所在。
我也更新了setuptools和wheel。
我也试过PIP_NO_BINARY=cppyy
以确保pipenv没有使用cppyy
的预制轮。
FROM ubuntu:18.04
ENV TZ=Europe/Amsterdam
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN export LC_ALL=C.UTF-8 && export LANG=C.UTF-8
RUN apt-get update && apt-get install -y python3.6
RUN apt-get install -y python3-pip
# Make sure proper symlinks are in place
RUN if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [ ! -e /usr/bin/python ]; then ln -sf /usr/bin/python3 /usr/bin/python; fi
RUN /usr/bin/pip install --upgrade pipenv setuptools wheel
RUN mkdir /config
COPY ./config /config
COPY ./backend /app
WORKDIR /app
RUN mkdir -p uploads
# Otherwise Pip starts whining about ASCII
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN apt-get install -y mysql-server libmysqlclient-dev
# Install Python deps
RUN pipenv install --clear --system --python=3.6
最后一行失败了。
Pipfile如下:
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = false
name = "pypi"
[global]
no-cache-dir = false
[packages]
pandas = "*"
numpy = "*"
seaborn = "*"
matplotlib = "*"
"jinja2" = "*"
imgkit = "*"
wkhtmltopdf = "*"
bokeh = "*"
flask = "*"
flask-socketio = "*"
eventlet = "*"
flask-cors = "*"
sqlalchemy = "*"
pyopenssl = "*"
gunicorn = "*"
xlrd = "*"
mysqlclient = "*"
sqlalchemy-utils = "*"
python-dateutil = "*"
pep8 = "*"
chardet = "*"
openpyxl = "*"
cppyy = "*"
[dev-packages]
pylint = "*"
python-dotenv = "*"
mysqlclient = "*"
matplotlib = "*"
Pipfile.lock的相关部分如下:
"cppyy": {
"hashes": [
"sha256:af7774eb8f7da934790b08e5e1b2b1ea514b3d1e0d07d71c3b73f6312389a473"
],
"index": "pypi",
"version": "==1.4.9"
},
"cppyy-backend": {
"hashes": [
"sha256:3cbfb92531cce600cbd8c469bc633d00dfc7d5e3d3a8b22b1596a8db9f8e9808"
],
"version": "==1.8.2"
},
"cppyy-cling": {
"hashes": [
"sha256:064644d15ea6a9d02ba613696c567b58c85343b0b78ac035af3bd1295cf5887a",
"sha256:3911b9ec8697c3fa43f6519e0b2c8006b25d2696d6a72aa46179783078b0fb20",
"sha256:49f02c76faaf0c882777f321ac2bdda375c6deff62df8bcf3b1f6a34ddf16697",
"sha256:7eaedb57eea1007569b8ecc3528414442ff0fb3df32a3afc57258ac3eeca0dc4",
"sha256:a0a36074536be9b945e23b6e607ceb59b489d2ef38fe99547e7afb6b6dc78029"
],
"version": "==6.15.2.7"
},
"cpycppyy": {
"hashes": [
"sha256:f2386f34499ab567e02456e5238b7d6a12883a57b632c3bbb8257058194fd19c"
],
"version": "==1.7.2"
},
预期的结果显然是来自pipenv的“安装成功”。实际的错误消息如下:
Installing dependencies from Pipfile.lock (57997e)…
An error occurred while installing cppyy==1.4.9 --hash=sha256:af7774eb8f7da934790b08e5e1b2b1ea514b3d1e0d07d71c3b73f6312389a473! Will try again.
An error occurred while installing cpycppyy==1.7.2 --hash=sha256:f2386f34499ab567e02456e5238b7d6a12883a57b632c3bbb8257058194fd19c! Will try again.
Installing initially failed dependencies…
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.6/dist-packages/pipenv/cli/command.py", line 254, in install
[pipenv.exceptions.InstallError]: editable_packages=state.installstate.editables,
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.6/dist-packages/pipenv/core.py", line 1874, in do_install
[pipenv.exceptions.InstallError]: keep_outdated=keep_outdated
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.6/dist-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.6/dist-packages/pipenv/core.py", line 862, in do_install_dependencies
[pipenv.exceptions.InstallError]: _cleanup_procs(procs, False, failed_deps_queue, retry=False)
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.6/dist-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Looking in indexes: https://pypi.python.org/simple', 'Collecting cppyy==1.4.9 (from -r /tmp/pipenv-o4uo_7oz-requirements/pipenv-mt1pg8se-requirement.txt (line 1))', ' Using cached https://files.pythonhosted.org/packages/e2/bf/46ab78ea7b5d804832cc6de4ae0d38b4543d334d323028cc6e2df4b6ae04/cppyy-1.4.9.tar.gz', 'Building wheels for collected packages: cppyy', ' Building wheel for cppyy (setup.py): started', " Building wheel for cppyy (setup.py): finished with status 'done'", ' Running setup.py clean for cppyy', 'Failed to build cppyy', 'Installing collected packages: cppyy', ' Running setup.py install for cppyy: started', " Running setup.py install for cppyy: finished with status 'error'"]
[pipenv.exceptions.InstallError]: ["WARNING: Legacy build of wheel for 'cppyy' created no files.", ' Command arguments: /usr/bin/python3 -u -c \'import setuptools, tokenize;__file__=\'"\'"\'/tmp/pip-install-41clln6n/cppyy/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-a3go9c51 --python-tag cp36', ' Command output: [use --verbose to show]', ' ERROR: Complete output from command /usr/bin/python3 -u -c \'import setuptools, tokenize;__file__=\'"\'"\'/tmp/pip-install-41clln6n/cppyy/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-77wl9so6/install-record.txt --single-version-externally-managed --compile:', ' ERROR: No eggs found in /tmp/easy_install-0dvwvzxr/CPyCppyy-1.7.2/egg-dist-tmp-94jvpfxp (setup script problem?)', ' Traceback (most recent call last):', ' File "<string>", line 1, in <module>', ' File "/tmp/pip-install-41clln6n/cppyy/setup.py", line 166, in <module>', ' zip_safe=False,', ' File "/usr/local/lib/python3.6/dist-packages/setuptools/__init__.py", line 144, in setup', ' _install_setup_requires(attrs)', ' File "/usr/local/lib/python3.6/dist-packages/setuptools/__init__.py", line 139, in _install_setup_requires', ' dist.fetch_build_eggs(dist.setup_requires)', ' File "/usr/local/lib/python3.6/dist-packages/setuptools/dist.py", line 717, in fetch_build_eggs', ' replace_conflicting=True,', ' File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 786, in resolve', ' raise DistributionNotFound(req, requirers)', " pkg_resources.DistributionNotFound: The 'CPyCppyy>=1.7.2' distribution was not found and is required by the application", ' ----------------------------------------', 'ERROR: Command "/usr/bin/python3 -u -c \'import setuptools, tokenize;__file__=\'"\'"\'/tmp/pip-install-41clln6n/cppyy/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-77wl9so6/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-41clln6n/cppyy/']
ERROR: ERROR: Package installation failed...
编辑:以下实际工作:
RUN pipenv install --clear --system --python=3.6; exit 0
RUN pipenv install --clear --system --python=3.6
第一次安装失败,但第二次安装没有任何麻烦。也许这有帮助。
由于它第二次成功,我最好的猜测是包没有按预期的顺序安装。或者在处理下一个包之前未完全安装。
根据日志文件片段,不清楚尝试的安装顺序是什么。显示的错误消息似乎只是为了cppyy,但它说的是如果b / c失败它无法找到CPyCppyy的鸡蛋,所以相关的错误消息应该来自那个。请注意,禁用轮子和蛋的构建,因为pip在尝试构建之前不会解析依赖关系。这意味着这样的构建会失败,或者如果恰好存在一个旧的安装(更糟糕的话)。
无论如何,订单必须是cppyy-cling,cppyy-backend,CPyCppyy,cppyy。 (这里解释了分裂背后的原因:https://cppyy.readthedocs.io/en/latest/packages.html#package-structure。)每个包都需要在下一个包之前完全安装:cling-config脚本(由cppyy-cling提供)用于传播编译器标志(特别是它传播哪个应该支持C ++标准),因此需要可用。