Reputation: 31
I'm unable to install azure-cognitiveservices-speech within a docker container using pip. My container is running fine and is able to install all other packages (django, google-cloud-translate, boto3 for example) without any issues using the following dockerfile.
FROM python:3.8.2
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
COPY . /code/
RUN pip install --no-cache-dir -r requirements.txt
COPY entrypoint.sh /code/entrypoint.sh
RUN chmod u+x /code/entrypoint.sh
amqp==5.0.2
asgiref==3.3.1
billiard==3.6.3.0
celery==5.0.4
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
dj-database-url==0.5.0
Django==3.1.3
django-crispy-forms==1.9.2
django-filter==2.4.0
django-rest-auth==0.9.5
djangorestframework==3.12.2
kombu==5.0.2
Markdown==3.3.3
prompt-toolkit==3.0.8
psycopg2==2.8.6
pytz==2020.4
six==1.15.0
sqlparse==0.4.1
vine==5.0.0
wcwidth==0.2.5
google-cloud-translate==3.0.2
django-storages==1.9.1
gunicorn==20.0.4
boto3==1.16.43
However, when azure-cognitiveservices-speech is added to this list, I am receiving the following error:
ERROR: Could not find a version that satisfies the requirement azure-cognitiveservices-speech (from versions: none)
ERROR: No matching distribution found for azure-cognitiveservices-speech
I have tried specifying the specific version of the module too.
I have simplified the dockerfile and specified running on Ubuntu alongside installing some dependencies that I have read from other resources (https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/747) may be required for the azure-cognitiveservices-speech package, however to no avail.
FROM ubuntu:18.04
RUN mkdir /code
WORKDIR /code
RUN apt-get update && apt-get install -y \
build-essential \
libssl1.0.0 \
libasound2 \
python3.7
RUN apt-get install -y python3-pip
ADD requirements.txt /code/
RUN pip3 install --upgrade pip
RUN pip3 install azure-cognitiveservices-speech
ADD . /code/
I have also tried multiple versions of Python within both versions of the docker container. However, I am still receiving the original error seen above.
Following this answer (Can't pip microsoft azure-cognitiveservices-speech?) I have run the original container and entered the terminal confirmed that I am running a suitable 64 bit version of python.
# python -c "import struct; print(struct.calcsize('P') * 8)"
64
Does anyone have a solution/appropriate enviroment to run this package within a container? Apologies for the long question, I have tried a whole host of things to get this package installed. Am I missing something fundamental?
Alternatively, is there another way to access this API without installing this package?
I am running this container on a M1 macbook pro, however I have attempted it on an older intel mac to see if this may be the problem and I am still seeing the same error.
Upvotes: 2
Views: 1346
Reputation: 1777
I also use a MacBook with an ARM chip, adding --platform=linux/amd64
to the official Python Docker image solved the problem for me.
Also make sure to install the latest version of the package as support from different platforms is limited.
azure-cognitiveservices-speech==1.19.0
worked at the time of this answer.
Upvotes: 0
Reputation: 31
So I seem to have finally got this working now. In honesty, I'm not sure I fully understand what has finally caused this pip install to start working. However, this is my first question here and I think it's best to just post what has fixed it for me in case anyone else runs into it.
FROM --platform=linux/amd64 ubuntu:18.04 AS myubuntu
RUN mkdir /code
WORKDIR /code
RUN apt-get update && apt-get install -y \
build-essential \
libssl1.0.0 \
libasound2 \
python3.6
RUN apt-get install -y python3-pip
RUN pip3 install --upgrade pip
ADD . /code/
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN pip3 install -r ./requirements.txt
Seems I needed to specify the platform (potentially a known error with Apple M1 preview version of docker), install the required ubuntu packages for azure-cognitiveservices-speech and then set the ENV variables as this was also causing an error.
Then build the image (with specifying network=host), tag it and the reference the local image within my docker-compose file as so.
docker build --network=host -t testinstall2 .
docker tag testinstall2:latest testinstall:staging
version: "3.8"
services:
db:
# restart: always
image: postgres:13.1
environment:
- POSTGRES_DB=
- POSTGRES_USER=
- POSTGRES_PASSWORD=
volumes:
- postgres_data:/var/lib/postgresql/data/
web:
image: testinstall:staging
entrypoint: /code/entrypoint.sh
volumes:
- .:/code
env_file: &envfile
- SecretKeys/env.env
ports:
- "8000:8000"
depends_on:
- db
- broker
celery:
image: testinstall:staging
restart: "no"
command : celery -A MyProject worker -l info
env_file: *envfile
volumes:
- .:/code
depends_on:
- db
- broker
celery-beat:
image: testinstall:staging
restart: "always"
command: celery -A MyProject beat -l info
env_file: *envfile
volumes:
- .:/code
depends_on:
- db
- broker
broker:
image: rabbitmq:3
env_file: *envfile
ports:
- 5672:5672
volumes:
postgres_data:
Following this all my containers and celery workers run as expected with the azure package. I would still be interested to understand what exactly was causing this if anyone has any ideas!
Upvotes: 1