I’m new to Docker and currently trying to create a Dockerfile with installing the python packages and its libraries as shown here:
FROM balenalib/fincm3-debian-python:latest
# RUN install_packages git
RUN apt-get update && apt-get install python
&& apt-get install pip3
apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
pip3 install pyaudio
pip3 install numpy
pip3 install matplotlib
pip3 install scipy
pip3 install librosa
# Set our working directory
WORKDIR /usr/src/app
COPY Recorder.py /usr/src/app
# Recorder.py will run when container starts up on the device
CMD ["python","/usr/src/app/Recorder.py"]
However, while I am trying to push this Dockerfile, the error is generated with
Error: The command '/bin/sh -c apt-get update && apt-get install python && apt-get install pip3 apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev pip3 install pyaudio
pip3 install numpy pip3 install matplotlib pip3 install scipy pip3 install librosa WORKDIR /usr/src/app' returned a non-zero code: 100
3
Answers
Moving python packages in requirements.txt and installing python3-pip worked with python:3 base image.
The package you are looking for is called
python3-pip
.Next, you need both
&&
(to separate commands) and(to continue the command line). So, in summary, that should be:
I believe you have more than one problem in this Dockerfile, and when you put all commands together with
&& and
, you don’t know which one is triggering the error. I suggest splitting them for debugging purposes, when they all work then you can put then together. Once you understand each individual error is easier to check and solve them. this question has valuable info: how to install pip in dockerTry this:
1- packages are triggers Y/n questions, give -y to guarantee it passes
2- using the backslashes to refer to a new command, you should use &&, backslashes refer to breaking line, you can use and then &&
3-
pip3
andlibportaudio0
packages doesn’t exist.I found out about the errors dividing the Dockerfile like this and removing the problems mentioned:
If you want to put the commands together:
I also suggest adding a pip requirements file, would make things cleaner.