Reputation: 667
I am very new to docker. I am building a docker for the first time. I have created a Dockerfile and need to add python packages (specifically to emails). However I am getting an error while building the docker file.
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"]
I am getting the following error:
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
I have installed these packages successfully in Pycharm and have no issues with it. I am not sure how to fix this in docker. Any help would be appreciated.
Upvotes: 4
Views: 23473
Reputation: 250
You will face a similar issue with "mimetypes" module too. Even this is part of python base and you don't need to install it manually. Also, you can have all the required modules in a requirements.txt file and install them at once. For that, you need to copy the requirements file into the docker image before running install.
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
Upvotes: 3
Reputation: 309
You didn't make a mistake. The cStringIO module doesn't exist anymore. Just remove the email module from your pip install since it is already a part of python base and you should be good to go.
Upvotes: 2