英文:
docker executor failed running
问题
I wrote a python script now I want to dockerize the script so I make a 'Dockerfile' and then I wrote docker build -t price_updater_service.py .
but in final step after copying my 'requirements.txt' i got this error 'executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt]: exit code: 2'. atually problem is that image can't download package listed in my 'requirements.txt'. what else I can to do? is this any other way? also I'll put my 'requirements.txt' and my 'Dockerfile' here:
'requirements.txt'
pandas==2.0
redis
Dockerfile
# Use the official Python base image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Copy the Python requirements file to the container
COPY requirements.txt .
# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the Python code to the container
COPY main.py .
# Run the Python script when the container starts
CMD ["python", "main.py"]
full error trace:
=> ERROR [4/5] RUN pip install --no-cache-dir -r requirements.txt 169.8s
------
> [4/5] RUN pip install --no-cache-dir -r requirements.txt:
#6 11.00 Collecting pandas==2.0
#6 12.16 Downloading pandas-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
#6 164.0 ━━━━ 1.3/12.4 MB 4.3 kB/s eta 0:42:42
#6 164.0 ERROR: Exception:
#6 164.0 Traceback (most recent call last):
...
#6 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
#7 94.84 return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
#7 94.84 return self._prepare_linked_requirement(req, parallel_builds)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 536, in _prepare_linked_requirement
#7 94.84 local_file = unpack_url(
...
英文:
I wrote a python script now I want to dockerize the script so I make a 'Dockerfile' and then I wrote docker build -t price_updater_service.py .
but in final step after copying my 'requirements.txt' i got this error 'executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt]: exit code: 2'.
atually problem is that image can't download package listed in my'requirements.txt'.
what else I can to do? is this any other way? also I'll put my 'requirements.txt' and my 'Dockerfile' here:
'requirements.txt'
pandas == 2.0
redis
Dockerfile
# Use the official Python base image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Copy the Python requirements file to the container
COPY requirements.txt .
# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the Python code to the container
COPY main.py .
# Run the Python script when the container starts
CMD [ "python", "main.py" ]
full error trace:
=> ERROR [4/5] RUN pip install --no-cache-dir -r requirements.txt 169.8s
------
> [4/5] RUN pip install --no-cache-dir -r requirements.txt:
#6 11.00 Collecting pandas==2.0
#6 12.16 Downloading pandas-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
#6 164.0 ━━━━ 1.3/12.4 MB 4.3 kB/s eta 0:42:42
#6 164.0 ERROR: Exception:
#6 164.0 Traceback (most recent call last):
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
#6 164.0 yield
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 561, in read
#6 164.0 data = self._fp_read(amt) if not fp_closed else b""
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
#6 164.0 return self._fp.read(amt) if amt is not None else self._fp.read()
#6 164.0 File "/usr/local/lib/python3.9/http/client.py", line 463, in read
#6 164.0 n = self.readinto(b)
#6 164.0 File "/usr/local/lib/python3.9/http/client.py", line 507, in readinto
#6 164.0 n = self.fp.readinto(b)
#6 164.0 File "/usr/local/lib/python3.9/socket.py", line 704, in readinto
#6 164.0 return self._sock.recv_into(b)
#6 164.0 File "/usr/local/lib/python3.9/ssl.py", line 1242, in recv_into
#6 164.0 return self.read(nbytes, buffer)
#6 164.0 File "/usr/local/lib/python3.9/ssl.py", line 1100, in read
#6 164.0 return self._sslobj.read(len, buffer)
#6 164.0 socket.timeout: The read operation timed out
#6 164.0
#6 164.0 During handling of the above exception, another exception occurred:
#6 164.0
#6 164.0 Traceback (most recent call last):
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
#6 164.0 status = run_func(*args)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
#6 164.0 return func(self, options, args)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 419, in run
#6 164.0 requirement_set = resolver.resolve(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
#6 164.0 result = self._result = resolver.resolve(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
#6 164.0 state = resolution.resolve(requirements, max_rounds=max_rounds)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
#6 164.0 self._add_to_criteria(self.state.criteria, r, parent=None)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
#6 164.0 if not criterion.candidates:
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
#6 164.0 return bool(self._sequence)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
#6 164.0 return any(self)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
#6 164.0 return (c for c in iterator if id(c) not in self._incompatible_ids)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
#6 164.0 candidate = func()
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
#6 164.0 self._link_candidate_cache = LinkCandidate(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 297, in __init__
#6 164.0 super().__init__(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
#6 164.0 self.dist = self._prepare()
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
#6 164.0 dist = self._prepare_distribution()
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
#6 164.0 return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
#6 164.0 return self._prepare_linked_requirement(req, parallel_builds)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 536, in _prepare_linked_requirement
#6 164.0 local_file = unpack_url(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 166, in unpack_url
#6 164.0 file = get_http_url(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 107, in get_http_url
#6 164.0 from_path, content_type = download(link, temp_dir.path)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/network/download.py", line 147, in __call__
#6 164.0 for chunk in chunks:
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar
#6 164.0 for chunk in iterable:
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks
#6 164.0 for chunk in response.raw.stream(
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream
#6 164.0 data = self.read(amt=amt, decode_content=decode_content)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 587, in read
#6 164.0 File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
#6 164.0 self.gen.throw(typ, value, traceback)
#6 164.0 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher
#6 164.0 raise ReadTimeoutError(self._pool, None, "Read timed out.")
#6 164.0 pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
#6 169.6
#6 169.6 [notice] A new release of pip is available: 23.0.1 -> 23.1.2
#6 169.6 [notice] To update, run: pip install --upgrade pip
------
executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt]: exit code: 2
PS C:\Users\hesam\OneDrive\Desktop\sam\python_django_test\price_update> docker build -t price_updater_service.py .
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 32B 0.0s
[+] Building 103.0s (8/9)
=> [internal] load build definition from Dockerfile 0.2s
=> => transferring dockerfile: 32B 0.1s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.9-slim 3.8s
=> [1/5] FROM docker.io/library/python:3.9-slim@sha256:5f0192a4f58a6ce99f732fe05e3b3d00f12ae62e183886bca3ebe3d202686c7f 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 81B 0.0s
=> CACHED [2/5] WORKDIR /app 0.0s
=> CACHED [3/5] COPY requirements.txt . 0.0s
=> ERROR [4/5] RUN pip install --no-cache-dir -r requirements.txt 99.0s
------
> [4/5] RUN pip install --no-cache-dir -r requirements.txt:
#7 53.23 Collecting pandas==2.0
#7 55.65 Downloading pandas-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
#7 94.83 0.0/12.4 MB 2.5 kB/s eta 1:21:34
#7 94.84 ERROR: Exception:
#7 94.84 Traceback (most recent call last):
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
#7 94.84 yield
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 561, in read
#7 94.84 data = self._fp_read(amt) if not fp_closed else b""
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
#7 94.84 return self._fp.read(amt) if amt is not None else self._fp.read()
#7 94.84 File "/usr/local/lib/python3.9/http/client.py", line 463, in read
#7 94.84 n = self.readinto(b)
#7 94.84 File "/usr/local/lib/python3.9/http/client.py", line 507, in readinto
#7 94.84 n = self.fp.readinto(b)
#7 94.84 File "/usr/local/lib/python3.9/socket.py", line 704, in readinto
#7 94.84 return self._sock.recv_into(b)
#7 94.84 File "/usr/local/lib/python3.9/ssl.py", line 1242, in recv_into
#7 94.84 return self.read(nbytes, buffer)
#7 94.84 File "/usr/local/lib/python3.9/ssl.py", line 1100, in read
#7 94.84 return self._sslobj.read(len, buffer)
#7 94.84 socket.timeout: The read operation timed out
#7 94.84
#7 94.84 During handling of the above exception, another exception occurred:
#7 94.84
#7 94.84 Traceback (most recent call last):
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
#7 94.84 status = run_func(*args)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
#7 94.84 return func(self, options, args)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 419, in run
#7 94.84 requirement_set = resolver.resolve(
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
#7 94.84 result = self._result = resolver.resolve(
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
#7 94.84 state = resolution.resolve(requirements, max_rounds=max_rounds)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
#7 94.84 self._add_to_criteria(self.state.criteria, r, parent=None)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
#7 94.84 if not criterion.candidates:
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
#7 94.84 return bool(self._sequence)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
#7 94.84 return any(self)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
#7 94.84 return (c for c in iterator if id(c) not in self._incompatible_ids)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
#7 94.84 candidate = func()
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
#7 94.84 self._link_candidate_cache = LinkCandidate(
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 297, in __init__
#7 94.84 super().__init__(
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
#7 94.84 self.dist = self._prepare()
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
#7 94.84 dist = self._prepare_distribution()
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
#7 94.84 return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
#7 94.84 return self._prepare_linked_requirement(req, parallel_builds)
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 536, in _prepare_linked_requirement
#7 94.84 local_file = unpack_url(
#7 94.84 File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line
答案1
得分: 0
这个问题是由于连接中断引起的。我在使用VPN时,Docker和pip都无法正常工作。
英文:
this problem is coz of conection intruption. i use VPN for docker and pip is not working well when you use VPN.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论