gpt4 book ai didi

python - Docker - 用于通过 pip 安装模块的 Python 依赖项

转载 作者:行者123 更新时间:2023-12-02 20:34:23 25 4
gpt4 key购买 nike

我正在使用 docker 构建 Django 实现。我使用 python 容器作为基础,但在我的需求文件中有以下内容:-

boto==2.43.0
boto3==1.4.4
botocore==1.5.55
ciscoconfparse==1.2.47
Django==1.11.4
django-appconf==1.0.2
django-auth-ldap==1.2.10
django-dbtemplates==2.0
django-debug-toolbar==1.7
easy-thumbnails==2.3
easysnmp==0.2.4
ipaddress==1.0.18
Jinja2==2.9.5
mysqlclient-1.3.10
netmiko==1.2.8
O365==0.9.5
orionsdk==0.0.6
paramiko==2.1.2
python-dateutil==2.6.0
python-ldap==2.4.32
pytz==2016.10
pyOpenSSL==17.2.0
sqlparse==0.2.3
urllib3==1.21.1
joblib==0.11

其中一些依赖项在单独使用 python 容器时会失败,例如...

   #include <net-snmp/net-snmp-config.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Failed building wheel for easysnmp
...
...
#include "lber.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Failed building wheel for pyldap
...
...
In file included from Modules/LDAPObject.c:9:0:
Modules/errors.h:8:18: fatal error: lber.h: No such file or directory
#include "lber.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aufmftap/pyldap/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-fjdz1te2-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-aufmftap/pyldap/

如何为 python 模块安装操作系统依赖项?在一个容器内? python 容器在什么操作系统上运行以获取正确的依赖项?

谢谢

最佳答案

假设您使用的是当前最新的 python:3.6 镜像,您需要安装一些额外的库。

Dockerfile 示例(pip 库在 requirements.txt 文件中):

FROM python:3.6

RUN apt-get update -y \
&& apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev libsnmp-dev

COPY requirements.txt requirements.txt

RUN pip install -r requirements.txt

相关问题:I can't install python-ldap

关于python - Docker - 用于通过 pip 安装模块的 Python 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45866296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com