我是码头工人的新手。我是第一次建造一个码头工人。我创建了一个Dockerfile,需要添加python包(特别是电子邮件)。但是,我在构建docker文件时遇到错误。
FROM alpine
MAINTAINER <[email protected]>
FROM python:3.7
RUN pip install --upgrade pip && \
pip install --no-cache-dir nibabel pydicom matplotlib pillow && \
pip install --no-cache-dir med2image
RUN pip install pandas xlsxwriter numpy boto boto3 botocore
RUN pip install oauth2client urllib3 httplib2 email mimetypes apiclient
RUN pip install snowflake.connector
ENV APP_HOME /Users/username/
ENV TZ=America/Los_Angeles
RUN mkdir -p $APP_HOME/code/
WORKDIR $APP_HOME
ENTRYPOINT [ "python"]
我收到以下错误:
Downloading https://files.pythonhosted.org/packages/71/e7/816030d3b0426c130040bd068be62b9213357ed02896f5d9badcf46d1b5f/email-4.0.2.tar.gz (1.2MB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 18, in <module>
import setuptools.version
File "/usr/local/lib/python3.7/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 36, in <module>
import email.parser
File "/tmp/pip-install-1m3cdjov/email/email/parser.py", line 10, in <module>
from cStringIO import StringIO
ModuleNotFoundError: No module named 'cStringIO'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-1m3cdjov/email/
The command '/bin/sh -c pip install oauth2client urllib3 httplib2 email mimetypes apiclient' returned a non-zero code: 1
我已经在Pycharm中成功安装了这些软件包,并且没有任何问题。我不知道如何解决这个问题。任何帮助,将不胜感激。
你也将面临与“mimetypes”模块类似的问题。即使这是python基础的一部分,您也不需要手动安装它。此外,您可以在requirements.txt文件中包含所有必需的模块,并立即安装它们。为此,您需要在运行安装之前将需求文件复制到docker镜像中。
requirements.txt
nibabel
pydicom
matplotlib
pillow
med2image
pandas
xlsxwriter
numpy
boto
boto3
botocore
oauth2client
urllib3
httplib2
apiclient
Dockerfile
FROM alpine
MAINTAINER <[email protected]>
FROM python:3.7
COPY requirements.txt /tmp
WORKDIR /tmp
RUN pip install --upgrade pip && \
pip install -r requirements.txt
你没有犯错。 cStringIO模块不再存在。只需从你的pip安装中删除电子邮件模块,因为它已经是python基础的一部分,你应该好好去。