0

I am have some problem while install pip package in docker image.

My Dockerfile is like this

....
RUN python -m venv /vir_env
RUN . /vir_env/bin/activate && pip install --upgrade pip
RUN pip install -r ./requirements.txt
....

My requirements.txt file is generate by pip freeze > requirements.txt

But when I run docker build it always error in package have "ubuntu" in there name python-apt==2.0.0+ubuntu0.20.4.6, distro-info===0.23ubuntu1

Error log:

....
#13 5.890 ERROR: No matching distribution found for python-apt==2.0.0+ubuntu0.20.4.6
#13 6.360 WARNING: You are using pip version 21.2.4; however, version 22.0.4 is available.
#13 6.360 You should consider upgrading via the '/vir_env/bin/python3 -m pip install --upgrade pip' command.
------
error: failed to solve: executor failed running [/bin/sh -c . /vir_env/bin/activate && pip3 install -r /requirements.txt]: exit code: 1
....
#13 5.890 ERROR: No matching distribution found for distro-info===0.23ubuntu1
#13 6.360 WARNING: You are using pip version 21.2.4; however, version 22.0.4 is available.
#13 6.360 You should consider upgrading via the '/vir_env/bin/python3 -m pip install --upgrade pip' command.
------
error: failed to solve: executor failed running [/bin/sh -c . /vir_env/bin/activate && pip3 install -r /requirements.txt]: exit code: 1

I already try pip upgrade but not don't work.

Is there any other way to fix or is there any update about this but I missed ?

Nhat Micls
  • 60
  • 2
  • 10
  • You might be using a non-Ubuntu container (e.g. Debian). Check the `FROM` line in your `Dockerfile`. – mkayaalp Mar 08 '22 at 04:43
  • @mkayaalp `FROM --platform=linux/amd64 ubuntu:20.04` this is my image container – Nhat Micls Mar 08 '22 at 06:52
  • [What is "pkg-resources==0.0.0" in output of pip freeze command](https://stackoverflow.com/questions/39577984/what-is-pkg-resources-0-0-0-in-output-of-pip-freeze-command) suggests this is a bug in the Ubuntu-packaged `virtualenv` tool. You might try re-running `pip freeze` on the host, maybe using `python3 -m venv` to create a new virtual environment first. – David Maze Mar 08 '22 at 11:35
  • @DavidMaze I just re-running `pip freeze` in docker so it not have any package name with `ubuntu` – Nhat Micls Mar 10 '22 at 04:14
  • sometimes is because the package doesn't exist for the version of ubuntu you are using. try upgrading or downgrading your ubuntu base – TecHunter Jun 28 '22 at 21:10

1 Answers1

0

I still don't know what problem is it.

But I make new ubuntu container and install package manually and try pip freeze > requirements.txt it don't generate any pip package with "ubuntu" in there name.

I think there is some problem with my docker or my pip package.

Nhat Micls
  • 60
  • 2
  • 10