deadsnakes / issues

Issues for https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
86 stars 6 forks source link

Python 3.7 : ModuleNotFoundError: No module named 'distutils.util' using Ubuntu 22.04 image #246

Closed rastarr closed 1 year ago

rastarr commented 1 year ago

Similar to https://github.com/deadsnakes/issues/issues/82, I'm also trying to build a docker image and get this dreaded 'ModuleNotFoundError: No module named 'distutils.util'' error message.

I've installed python3.7 python3.7-venv python3.7-distutils python3.7-lib2to3 python3.7-gdbm python3.7-tk but still the error comes up.

Do I need to change any python code (newbie here just trying to get this to work)

Any help would be great

asottile commented 1 year ago

show your actual reproduction?

rastarr commented 1 year ago

Oops, sorry, my 'github newbieness' is showing

This is from the repo at https://github.com/punkerpunker/captcha_solver

`martin@u2204:~/Documents/captcha_solver$ docker-compose up -d --build captcha-solver Building captcha-solver [+] Building 9.5s (12/13)
=> [internal] load build definition from Dockerfile 0.7s => => transferring dockerfile: 331B 0.0s => [internal] load .dockerignore 0.5s => => transferring context: 2B 0.1s => [internal] load metadata for docker.io/library/ubuntu:focal 4.3s => [internal] load build context 0.2s => => transferring context: 126B 0.0s => [1/9] FROM docker.io/library/ubuntu:focal@sha256:24a0df437301598d1a4b62ddf59fa0ed2969150d70d748c84225e6501e9c36b9 0.0s => CACHED [2/9] RUN apt-get update 0.0s => CACHED [3/9] RUN apt-get -y install software-properties-common 0.0s => CACHED [4/9] RUN add-apt-repository ppa:deadsnakes/ppa 0.0s => CACHED [5/9] RUN apt-get update 0.0s => CACHED [6/9] RUN apt-get -y install libgl1-mesa-glx python3.7 python3-pip 0.0s => CACHED [7/9] COPY requirements.txt . 0.0s => ERROR [8/9] RUN python3.7 -m pip install -r requirements.txt 4.2s


[8/9] RUN python3.7 -m pip install -r requirements.txt:

0 2.969 Traceback (most recent call last):

0 2.969 File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main

0 2.969 "main", mod_spec)

0 2.969 File "/usr/lib/python3.7/runpy.py", line 85, in _run_code

0 2.969 exec(code, run_globals)

0 2.969 File "/usr/lib/python3/dist-packages/pip/main.py", line 16, in

0 2.969 from pip._internal.cli.main import main as _main # isort:skip # noqa

0 2.969 File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in

0 2.969 from pip._internal.cli.autocompletion import autocomplete

0 2.969 File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in

0 2.969 from pip._internal.cli.main_parser import create_main_parser

0 2.969 File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in

0 2.969 from pip._internal.cli import cmdoptions

0 2.969 File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in

0 2.969 from distutils.util import strtobool

0 2.969 ModuleNotFoundError: No module named 'distutils.util'


Dockerfile:10

8 |
9 | COPY requirements.txt . 10 | >>> RUN python3.7 -m pip install -r requirements.txt 11 | ADD . . 12 |

ERROR: failed to solve: process "/bin/sh -c python3.7 -m pip install -r requirements.txt" did not complete successfully: exit code: 1 ERROR: Service 'captcha-solver' failed to build : Build failed `

asottile commented 1 year ago

ok so you say you're installing python#.#-distutils but you're not

rastarr commented 1 year ago

I've installed it on the Ubuntu system but I have no idea where or how to do so in the docker build phase. I thought that may be a problem

asottile commented 1 year ago

docker is entirely isolated from the host. you need to install inside the image

rastarr commented 1 year ago

OK, thank you so much for pointing me in the right direction. I think I got it sorted now. Thank you again