Pushing image not working

Hi all, I met a problem that I successfully pushed the Dockerfile to balena cloud, however, it shows the error in Logs window and the application cannot be applied. It seems like the pyaudio is not imported, however, I cannot find what the problem is.

My Docker file is shown as:

FROM balenalib/fincm3-debian-python:latest

#RUN install_packages git

RUN apt-get update
RUN apt-get install python -y
&& apt-get install python3-pip -y
RUN apt-get install build-essential -y
RUN apt-get install -y python3-dev -y
RUN apt-get install python3-setuptools -y
RUN apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev -y
RUN pip3 install wheel
RUN pip3 install pyaudio numpy matplotlib scipy

WORKDIR /usr/src/app

#COPY requirements.txt ./
COPY Recorder.py /usr/src/app

CMD [“python”,“/usr/src/app/Recorder.py”]`

And the Logs window shows

You seem to be installing pyaudio into the Python 3 installation, but then run your application with the interpreter provided by the default installation in the base image. Can you try CMD [“python3”,"/usr/src/app/Recorder.py"] instead?

@dfunckt Thanks it works. But it generates another import error that

But I checked the numpy version (1.18.4) and python version (3.7) are correct

hey @Xia,
can you confirm which module cannot be imported? it is not clear from the above screenshot
also, just to confirm, have you tried this on your machine and can confirm it works with similar python and library versions?

@rahul-thakoor I cannot import numpy. I tried this on my machine and it works. I am not sure why it works in Pythonon my laptop but not after I pushed and ran on Balena Fin

@rahul-thakoor I basically reinstalled numpy to the certain version of 1.18.4, and included in Dockerfile and pushed the image, but it still shows error for Importerror of numpy

hey @Xia,
Can you try to use balena build command to make sure that the project builds successfully? here are the relevant docs

perhaps you are missing some dependencies for numpy?

Hello @Xia , I’ve tested with the following Dockerfile, importing pyaudio works fine.
Just replace amd64 with fincm3 if you’re using a Fin in the FROM line.

FROM balenalib/amd64-debian-python:latest

RUN \
	apt-get update && \
	apt-get install -y \
		build-essential \
		libportaudio2 \
		libportaudiocpp0 \
		portaudio19-dev \
		python3 \
		python3-dev \
		python3-pip \
		python3-setuptools

RUN pip3 install wheel
RUN pip3 install pyaudio numpy matplotlib scipy

COPY Recorder.py /usr/src/app/

CMD ["/usr/bin/python3", "/usr/src/app/Recorder.py"]`

@zvin Hi, it pops up an error message on Run apt-get update:
image

exec format error means you’re running some code that’s intended for a different architecture. What type of architecture does your local device have (where you are running build command)?

@karaxuna Hi, how can i find the info of my local device system architecture?

Depends on what operating system you are running. See: https://unix.stackexchange.com/a/12454

Also I noticed that you are using FROM balenalib/amd64-debian-python:latest which resolves to 2.7.16. I think you need python 3. See https://hub.docker.com/r/balenalib/amd64-debian-python under title Supported versions and respective Dockerfile links

@karaxuna its x64 Windows. I tried with pythons 3 but the error is still shows with Importerror of Numpy. I am wondering why the pyaudio is successful but Numpy shows error.

Hi

We have a repo where we need a similar setup - you can take a look at that here

You’ll notice that

  • it is running debian:stretch
  • python is installed using the RUN install_packages command
  • numpy is installed by from requirements.txt in the top level dir.

Can you try to do something similar?

@anujdeshpande Do I need to specify the version of Numpy and other packages in requirement txt?

No need - see https://github.com/balena-io/heattest/blob/master/requirements.txt

@anujdeshpande it shows the same error as

I think the problem is amd64 since it is OK if I use fincm3. But neither of them can import Numpy

Can you share your dockerfile as it is right now?

@anujdeshpande image
And the requirement txt. :
image