由于requirements.txt文件,我无法构建docker镜像。谁能告诉我这个问题吗?

问题描述 投票:0回答:1

当我尝试构建 docker 映像时,它说 requests.txt 文件未成功运行并且发生安装依赖项错误。 这是我得到的终端响应,我无法理解任何修复它的建议。

602.3   Installing build dependencies: started
661.6   Installing build dependencies: finished with status 'error'
661.7   error: subprocess-exited-with-error
661.7
661.7   × pip subprocess to install build dependencies did not run successfully.
661.7   │ exit code: 1
661.7   ╰─> [56 lines of output]
661.7       Ignoring numpy: markers 'python_version < "3.11"' don't match your environment
661.7       Collecting numpy~=1.23.3
661.7         Downloading numpy-1.23.5.tar.gz (10.7 MB)
661.7            ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.7/10.7 MB 126.0 kB/s eta 0:00:00
661.7         Installing build dependencies: started
661.7         Installing build dependencies: finished with status 'done'
661.7         Getting requirements to build wheel: started
661.7         Getting requirements to build wheel: finished with status 'error'
661.7         error: subprocess-exited-with-error
661.7
661.7         × Getting requirements to build wheel did not run successfully.
661.7         │ exit code: 1
661.7         ╰─> [33 lines of output]
661.7             Traceback (most recent call last):
661.7               File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
661.7                 main()
661.7               File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
661.7                 json_out['return_val'] = hook(**hook_input['kwargs'])
661.7                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
661.7               File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build
_wheel
661.7                 backend = _build_backend()
661.7                           ^^^^^^^^^^^^^^^^
661.7               File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
661.7                 obj = import_module(mod_path)
661.7                       ^^^^^^^^^^^^^^^^^^^^^^^
661.7               File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
661.7                 return _bootstrap._gcd_import(name[level:], package, level)
661.7                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
661.7               File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
661.7               File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
661.7               File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
661.7               File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
661.7               File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
661.7               File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
661.7               File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
661.7               File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
661.7               File "<frozen importlib._bootstrap_external>", line 994, in exec_module
661.7               File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
661.7               File "/tmp/pip-build-env-8lohyq2y/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
661.7                 import setuptools.version
661.7               File "/tmp/pip-build-env-8lohyq2y/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
661.7                 import pkg_resources
661.7               File "/tmp/pip-build-env-8lohyq2y/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2172, in <module>
661.7                 register_finder(pkgutil.ImpImporter, find_on_path)
661.7                                 ^^^^^^^^^^^^^^^^^^^
661.7             AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
661.7             [end of output]
661.7
661.7         note: This error originates from a subprocess, and is likely not a problem with pip.
661.7       error: subprocess-exited-with-error
661.7
661.7       × Getting requirements to build wheel did not run successfully.
661.7       │ exit code: 1
661.7       ╰─> See above for output.
661.7
661.7       note: This error originates from a subprocess, and is likely not a problem with pip.
661.7       [end of output]
661.7
661.7   note: This error originates from a subprocess, and is likely not a problem with pip.
661.7 error: subprocess-exited-with-error
661.7
661.7 × pip subprocess to install build dependencies did not run successfully.
661.7 │ exit code: 1
661.7 ╰─> See above for output.
661.7
661.7 note: This error originates from a subprocess, and is likely not a problem with pip.
------
Dockerfile:11
--------------------
   9 |     COPY requirements.txt /app/emailclassifier
  10 |     
  11 | >>> RUN pip install -r requirements.txt
  12 |
  13 |     COPY . .
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1
PS C:\Users\NEW SKY\Downloads\Python Projects\Email Classifier FastAPI>

这是包含所有命令的 docker 文件。

这是我的Dockerfile

FROM python

RUN pip install --upgrade pip

RUN mkdir -p /app/emailclassifier

WORKDIR /app/emailclassifier

COPY requirements.txt /app/emailclassifier

RUN pip install -r requirements.txt

COPY . .

CMD ["uvicorn", "app.api:app", "--host", "0.0.0.0", "--port", "80"]

这是需求文件,其中包含要安装在容器映像上的所有依赖项。 这是我的要求.txt

absl-py==2.0.0
aiofiles==23.2.1
aiohttp==3.8.6
aiosignal==1.3.1
altair==5.1.2
annotated-types==0.5.0
anyio==3.7.0
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens==2.2.1
astunparse==1.6.3
async-timeout==4.0.3
asyncer==0.0.2
attrs==23.1.0
backcall==0.2.0
backoff==2.2.1
beautifulsoup4==4.12.2
bidict==0.22.1
bleach==6.0.0
blinker==1.6.3
bs4==0.0.1
cachetools==5.3.2
certifi==2023.5.7
cffi==1.15.1
chainlit==0.7.400
charset-normalizer==3.2.0
click==8.1.7
colorama==0.4.6
comm==0.1.3
comtypes==1.2.0
contourpy==1.0.7
cycler==0.11.0
dataclasses-json==0.5.14
debugpy==1.6.7
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.14
EasyProcess==1.1
entrypoint2==1.1
executing==1.2.0
fastapi==0.100.1
fastapi-socketio==0.0.10
fastjsonschema==2.17.1
filetype==1.2.0
Flask==3.0.0
flatbuffers==23.5.26
fonttools==4.39.4
fqdn==1.5.1
frozenlist==1.4.0
gast==0.5.4
gitdb==4.0.11
GitPython==3.1.40
google-auth==2.23.4
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
googleapis-common-protos==1.61.0
greenlet==3.0.1
grpcio==1.59.2
h11==0.14.0
h5py==3.10.0
html5lib==1.1
htmlmin==0.1.12
httpcore==0.18.0
httpx==0.25.0
idna==3.4
ImageHash==4.3.1
importlib-metadata==6.8.0
ipykernel==6.23.1
ipython==8.13.2
ipython-genutils==0.2.0
ipywidgets==8.0.6
isoduration==20.11.0
itsdangerous==2.1.2
jedi==0.18.2
Jinja2==3.1.2
joblib==1.1.1
jsonpatch==1.33
jsonpointer==2.3
jsonschema==4.17.3
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-events==0.6.3
jupyter_client==8.2.0
jupyter_core==5.3.0
jupyter_server==2.6.0
jupyter_server_terminals==0.4.4
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.7
keras==2.15.0
kiwisolver==1.4.4
langchain==0.0.327
langsmith==0.0.56
Lazify==0.4.0
libclang==16.0.6
Markdown==3.5.1
markdown-it-py==3.0.0
MarkupSafe==2.1.2
marshmallow==3.20.1
matplotlib==3.7.1
matplotlib-inline==0.1.6
mdurl==0.1.2
missingno==0.5.2
mistune==2.0.5
ml-dtypes==0.2.0
MouseInfo==0.1.3
mss==9.0.1
multidict==6.0.4
multimethod==1.9.1
mypy-extensions==1.0.0
nbclassic==1.0.0
nbclient==0.8.0
nbconvert==7.4.0
nbformat==5.8.0
nest-asyncio==1.5.6
networkx==3.1
nltk==3.8.1
nodeenv==1.8.0
notebook==6.5.4
notebook_shim==0.2.3
numpy==1.24.3
oauthlib==3.2.2
openai==0.28.1
opencv-python==4.8.0.74
opentelemetry-api==1.20.0
opentelemetry-exporter-otlp==1.20.0
opentelemetry-exporter-otlp-proto-common==1.20.0
opentelemetry-exporter-otlp-proto-grpc==1.20.0
opentelemetry-exporter-otlp-proto-http==1.20.0
opentelemetry-instrumentation==0.41b0
opentelemetry-proto==1.20.0
opentelemetry-sdk==1.20.0
opentelemetry-semantic-conventions==0.41b0
opt-einsum==3.3.0
overrides==7.3.1
packaging==23.1
pandas==2.0.2
pandas-profiling==3.2.0
pandocfilters==1.5.0
parso==0.8.3
patsy==0.5.3
phik==0.12.3
pickleshare==0.7.5
Pillow==9.5.0
platformdirs==3.5.1
plotly==5.15.0
plotly-express==0.4.1
prisma==0.10.0
prometheus-client==0.17.0
prompt-toolkit==3.0.38
protobuf==4.23.4
psutil==5.9.5
pure-eval==0.2.2
pyarrow==13.0.0
pyasn1==0.5.0
pyasn1-modules==0.3.0
PyAutoGUI==0.9.54
pycparser==2.21
pydantic==2.0.2
pydantic_core==2.1.2
pydeck==0.8.1b0
PyGetWindow==0.0.9
Pygments==2.15.1
PyJWT==2.8.0
PyMsgBox==1.0.9
pyparsing==3.0.9
PyPDF2==3.0.1
pyperclip==1.8.2
pypiwin32==223
PyQt5==5.15.9
PyQt5-Qt5==5.15.2
PyQt5-sip==12.12.1
PyRect==0.2.0
pyrsistent==0.19.3
pyscreenshot==3.1
PyScreeze==0.1.29
python-dateutil==2.8.2
python-dotenv==1.0.0
python-engineio==4.8.0
python-graphql-client==0.4.3
python-json-logger==2.0.7
python-multipart==0.0.6
python-socketio==5.10.0
pyttsx3==2.90
pytweening==1.0.7
pytz==2023.3
PyWavelets==1.4.1
pywin32==306
pywinpty==2.0.10
PyYAML==6.0
pyzmq==25.1.0
qtconsole==5.4.3
QtPy==2.3.1
regex==2023.10.3
requests==2.31.0
requests-oauthlib==1.3.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.6.0
rsa==4.9
scikit-learn==1.3.0
scipy==1.11.1
seaborn==0.12.2
Send2Trash==1.8.2
simple-websocket==1.0.0
six==1.16.0
sklearn==0.0.post7
smmap==5.0.1
sniffio==1.3.0
soupsieve==2.4.1
SQLAlchemy==2.0.22
stack-data==0.6.2
starlette==0.27.0
statsmodels==0.14.0
streamlit==1.28.0
syncer==2.0.3
tangled-up-in-unicode==0.2.0
tenacity==8.2.2
tensorboard==2.15.1
tensorboard-data-server==0.7.2
tensorflow==2.15.0
tensorflow-estimator==2.15.0
tensorflow-intel==2.15.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.3.0
terminado==0.17.1
threadpoolctl==3.2.0
tinycss2==1.2.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.12.1
toolz==0.12.0
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
typing-inspect==0.9.0
typing_extensions==4.7.1
tzdata==2023.3
tzlocal==5.2
uptrace==1.20.2
uri-template==1.2.0
urllib3==2.0.3
utils==1.0.1
uvicorn==0.23.2
validators==0.22.0
visions==0.7.4
watchdog==3.0.0
watchfiles==0.20.0
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.5.2
websockets==12.0
Werkzeug==3.0.1
widgetsnbextension==4.0.7
wrapt==1.14.1
wsproto==1.2.0
xlrd==2.0.1
yarl==1.9.2
zipp==3.17.0
docker dockerfile docker-registry
1个回答
0
投票

您的

requirements.txt
文件会安装
numpy==1.24..3
,但在版本 1.26.0 中添加了对 Python 3.12 的支持。因此,要么升级您的 numpy
 版本,要么将 
Dockerfile
 中的 Python 版本固定到 3.11 或更早版本。

© www.soinside.com 2019 - 2024. All rights reserved.