Skip to content

running pip install -r requirements.txt fails when trying to build an image #874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
exxterixs opened this issue Oct 6, 2023 · 2 comments

Comments

@exxterixs
Copy link

exxterixs commented Oct 6, 2023

My Dockerfile:

FROM python:3.7

WORKDIR /fastapi-app

COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
COPY . /tmp/

COPY ./app ./app

CMD ["python","./app/main.py"]`

requirements.txt:

annotated-types==0.5.0
anyio==3.7.1
click==8.1.7
exceptiongroup==1.1.3
fastapi==0.103.2
h11==0.14.0
idna==3.4
importlib-metadata==6.7.0
pydantic==2.4.2
pydantic_core==2.10.1
sniffio==1.3.0
starlette==0.27.0
typing_extensions==4.7.1
uvicorn==0.22.0
uvloop==0.17.0
websockets==11.0.3
zipp==3.15.0

error:

docker build -t python-fastapi .
[+] Building 5.1s (8/10)                                                                                                                                                                                                             
 => [internal] load build definition from Dockerfile                                                                                                                                                                            0.0s
 => => transferring dockerfile: 225B                                                                                                                                                                                            0.0s
 => [internal] load .dockerignore                                                                                                                                                                                               0.0s
 => => transferring context: 2B                                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/python:3.7                                                                                                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                                               1.9s
 => => transferring context: 37.49MB                                                                                                                                                                                            1.9s
 => [1/6] FROM docker.io/library/python:3.7                                                                                                                                                                                     0.0s
 => CACHED [2/6] WORKDIR /fastapi-app                                                                                                                                                                                           0.0s
 => [3/6] COPY requirements.txt /tmp/                                                                                                                                                                                           0.3s
 => ERROR [4/6] RUN pip install --requirement /tmp/requirements.txt                                                                                                                                                             2.8s
------                                                                                                                                                                                                                               
 > [4/6] RUN pip install --requirement /tmp/requirements.txt:                                                                                                                                                                        
#8 2.136 Collecting annotated-types==0.5.0                                                                                                                                                                                           
#8 2.267   Downloading annotated_types-0.5.0-py3-none-any.whl (11 kB)                                                                                                                                                                
#8 2.349 Collecting anyio==3.7.1                                                                                                                                                                                                     
#8 2.367   Downloading anyio-3.7.1-py3-none-any.whl (80 kB)                                                                                                                                                                          
#8 2.379 ERROR: Exception:
#8 2.379 Traceback (most recent call last):
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
#8 2.379     status = run_func(*args)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
#8 2.379     return func(self, options, args)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 420, in run
#8 2.379     reqs, check_supported_wheels=not options.target_dir
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 93, in resolve
#8 2.379     collected.requirements, max_rounds=try_to_avoid_resolution_too_deep
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
#8 2.379     state = resolution.resolve(requirements, max_rounds=max_rounds)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
#8 2.379     self._add_to_criteria(self.state.criteria, r, parent=None)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
#8 2.379     if not criterion.candidates:
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
#8 2.379     return bool(self._sequence)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
#8 2.379     return any(self)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
#8 2.379     return (c for c in iterator if id(c) not in self._incompatible_ids)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
#8 2.379     candidate = func()
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 211, in _make_candidate_from_link
#8 2.379     version=version,
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 303, in __init__
#8 2.379     version=version,
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
#8 2.379     self.dist = self._prepare()
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
#8 2.379     dist = self._prepare_distribution()
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
#8 2.379     return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
#8 2.379     return self._prepare_linked_requirement(req, parallel_builds)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 542, in _prepare_linked_requirement
#8 2.379     hashes,
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 170, in unpack_url
#8 2.379     hashes=hashes,
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 107, in get_http_url
#8 2.379     from_path, content_type = download(link, temp_dir.path)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/download.py", line 147, in __call__
#8 2.379     for chunk in chunks:
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/progress_bars.py", line 52, in _rich_progress_bar
#8 2.379     with progress:
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/rich/progress.py", line 1169, in __enter__
#8 2.379     self.start()
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/rich/progress.py", line 1160, in start
#8 2.379     self.live.start(refresh=True)
#8 2.379   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/rich/live.py", line 132, in start
#8 2.379     self._refresh_thread.start()
#8 2.379   File "/usr/local/lib/python3.7/threading.py", line 852, in start
#8 2.379     _start_new_thread(self._bootstrap, ())
#8 2.379 RuntimeError: can't start new thread
#8 2.628 
#8 2.628 [notice] A new release of pip is available: 23.0.1 -> 23.2.1
#8 2.628 [notice] To update, run: pip install --upgrade pip
------
executor failed running [/bin/sh -c pip install --requirement /tmp/requirements.txt]: exit code: 2

I tried googling for my issue but nothing seems to be helpful in my case. any suggestions what it might be?

@ad-m-ss
Copy link

ad-m-ss commented Oct 6, 2023

Duplicate of #835

@yosifkit
Copy link
Member

yosifkit commented Oct 6, 2023

So, the answer is likely #837 (comment)

@yosifkit yosifkit closed this as completed Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants