ModuleNotFoundError:创建 Dockerfile 时没有名为“OpenSSL”的模块

问题描述 投票:0回答:1

我为在端口 3000 上运行的 Flask 应用程序创建 docker 文件。 这是我的 docker 文件

<-----------------Dockerfile------------------------>

FROM python:3
WORKDIR /app
EXPOSE 3000
COPY    ./requirements.txt ./
RUN     pip install -r requirements.txt
COPY    ./ ./
CMD     ["python","run.py"]

<--------------------- 需求.txt------------------------------------------------>

我使用“pipreqs”生成它

pyOpenSSL==20.0.1
Flask_Login==0.5.0
SQLAlchemy==1.3.12
Flask_WTF==0.15.1
WTForms==2.3.3
Flask_SQLAlchemy==2.5.1
Flask_Bcrypt==0.7.1
Flask==2.0.1
Pillow==8.3.2
secrets==1.0.2

<------------------------------我遇到的错误-------------------------------------------->

E

RROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py'"'"'; __file__='"'"'/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ub_x6ltz
         cwd: /tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/
    Complete output (12 lines):
    Traceback (most recent call last):
      File "/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py", line 10, in <module>
        import OpenSSL
    ModuleNotFoundError: No module named 'OpenSSL'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py", line 12, in <module>
        raise ImportError('Installing this module requires OpenSSL python bindings')
    ImportError: Installing this module requires OpenSSL python bindings
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/93/c4/166925e31bc06bfe49deb4dc3922584790a33b897509bac388acdc074a60/secrets-1.0.2.tar.gz#sha256=37075ab08607092e76da2b86e94dd38a0216ec80088a0a3f9220077750aeddf9 (from https://pypi.org/simple/secrets/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement secrets==1.0.2 (from versions: 1.0.2)
ERROR: No matching distribution found for secrets==1.0.2

我什至在requirements.txt中添加了pyOpenSSL,但错误一直这样说。我是否选择了错误的 python 镜像?跟这个有关系吗

docker flask pyopenssl
1个回答
0
投票

考虑安装额外的软件包:


FROM python:3
WORKDIR /app
EXPOSE 3000

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

COPY    ./requirements.txt ./
RUN     pip install -r requirements.txt
COPY    ./ ./
CMD     ["python","run.py"]

(从这里得到答案:我无法安装python-ldap

© www.soinside.com 2019 - 2024. All rights reserved.