Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to install any python package in docker container

Tags:

python

docker

I am trying to create an docker image with ubutu 16.04 as base. I want to install few python packages like pandas, flask etc. I have kept all packages in "requirements.txt". But when I am trying to build image, I am getting

Could not find a version that satisfies the requirement requests (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for requests (from -r requirements.txt (line 1))

Basically, I have not mentioned any version in "requirements.txt". I guess it should take the latest available and compatible version of that package. But for every package same issue I am getting.

My DockerFile is as follows.

FROM ubuntu:16.04

RUN apt-get update -y && \
    apt-get install -y python3-pip python3-dev build-essential cmake pkg-config libx11-dev libatlas-base-dev

# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /testing/requirements.txt

WORKDIR /testing

RUN pip3 install -r requirements.txt

and requirements.txt is.

pandas
requests
PyMySQL
Flask
Flask-Cors
Pillow
face-recognition
Flask-SocketIO

Where I am doing wrong ? Can anybody help ?

like image 568
Bhimasen Avatar asked Oct 25 '25 10:10

Bhimasen


1 Answers

I too ran into the same situation. I observed that, python packages is looking for the network within docker. It is thinking that, it is running in a standalone without network so its not able to locate the package. In these type of situations either

No matching distribution found

or sometimes

Retrying ...

error may occur.

I used a --network option in the docker build command like below to overcome this error where the command insists python to use the host network to download the required packages.

docker build --network=host -t tracker:latest .

like image 91
Shastry Avatar answered Oct 27 '25 00:10

Shastry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!