У меня проблема с созданием образа докера для моего сервера Python.
при запуске: docker image build -t server:latest .
я получаю следующую ошибку:
=> ERROR [4/6] RUN pip3 install -r requirements.txt 11.2s
------
> [4/6] RUN pip3 install -r requirements.txt:
#9 1.220 Collecting cryptography==38.0.1
#9 1.328 Downloading cryptography-38.0.1-cp36-abi3-manylinux_2_28_x86_64.whl (4.2 MB)
#9 2.034 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 5.9 MB/s eta 0:00:00
#9 2.084 Collecting xeddsa==0.6.0
#9 2.099 Downloading XEdDSA-0.6.0.tar.gz (89 kB)
#9 2.117 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.5/89.5 KB 5.6 MB/s eta 0:00:00
#9 2.153 Preparing metadata (setup.py): started
#9 10.94 Preparing metadata (setup.py): finished with status 'error'
#9 10.95 error: subprocess-exited-with-error
#9 10.95
#9 10.95 × python setup.py egg_info did not run successfully.
#9 10.95 │ exit code: 1
#9 10.95 ╰─> [58 lines of output]
#9 10.95 Collecting cmake
#9 10.95 Downloading cmake-3.24.1.1-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.3 MB)
#9 10.95 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23.3/23.3 MB 5.5 MB/s eta 0:00:00
#9 10.95 Installing collected packages: cmake
#9 10.95 WARNING: The scripts cmake, cpack and ctest are installed in '/root/.local/bin' which is not on PATH.
#9 10.95 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
#9 10.95 Successfully installed cmake-3.24.1.1
#9 10.95 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#9 10.95 WARNING: You are using pip version 22.0.4; however, version 22.3 is available.
#9 10.95 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
#9 10.95 /usr/local/lib/python3.8/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
#9 10.95 warnings.warn(
#9 10.95 Traceback (most recent call last):
#9 10.95 File "ref10/build.py", line 39, in call_cmake
#9 10.95 subprocess.check_call([ "cmake", "-G", output, ".." ], cwd = build_dir)
#9 10.95 File "/usr/local/lib/python3.8/subprocess.py", line 359, in check_call
#9 10.95 retcode = call(*popenargs, **kwargs)
#9 10.95 File "/usr/local/lib/python3.8/subprocess.py", line 340, in call
#9 10.95 with Popen(*popenargs, **kwargs) as p:
#9 10.95 File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
#9 10.95 self._execute_child(args, executable, preexec_fn, close_fds,
#9 10.95 File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
#9 10.95 raise child_exception_type(errno_num, err_msg, err_filename)
#9 10.95 FileNotFoundError: [Errno 2] No such file or directory: 'cmake'
#9 10.95
#9 10.95 During handling of the above exception, another exception occurred:
#9 10.95
#9 10.95 Traceback (most recent call last):
#9 10.95 File "<string>", line 2, in <module>
#9 10.95 File "<pip-setuptools-caller>", line 34, in <module>
#9 10.95 File "/tmp/pip-install-27a8cwpi/xeddsa_5642cb3382374f11abad1422799f8339/setup.py", line 51, in <module>
#9 10.95 setup(
#9 10.95 File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 87, in setup
#9 10.95 return distutils.core.setup(**attrs)
#9 10.95 File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 147, in setup
#9 10.95 _setup_distribution = dist = klass(attrs)
#9 10.95 File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 476, in __init__
#9 10.95 _Distribution.__init__(
#9 10.95 File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 282, in __init__
#9 10.95 self.finalize_options()
#9 10.95 File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 900, in finalize_options
#9 10.95 ep(self)
#9 10.95 File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 920, in _finalize_setup_keywords
#9 10.95 ep.load()(self, ep.name, value)
#9 10.95 File "/tmp/pip-install-27a8cwpi/xeddsa_5642cb3382374f11abad1422799f8339/.eggs/cffi-1.15.1-py3.8-linux-x86_64.egg/cffi/setuptools_ext.py", line 219, in cffi_modules
#9 10.95 add_cffi_module(dist, cffi_module)
#9 10.95 File "/tmp/pip-install-27a8cwpi/xeddsa_5642cb3382374f11abad1422799f8339/.eggs/cffi-1.15.1-py3.8-linux-x86_64.egg/cffi/setuptools_ext.py", line 49, in add_cffi_module
#9 10.95 execfile(build_file_name, mod_vars)
#9 10.95 File "/tmp/pip-install-27a8cwpi/xeddsa_5642cb3382374f11abad1422799f8339/.eggs/cffi-1.15.1-py3.8-linux-x86_64.egg/cffi/setuptools_ext.py", line 25, in execfile
#9 10.95 exec(code, glob, glob)
#9 10.95 File "ref10/build.py", line 76, in <module>
#9 10.95 call_cmake("Unix Makefiles")
#9 10.95 File "ref10/build.py", line 55, in call_cmake
#9 10.95 os.path.append(os.path.expanduser("~/.local/bin"))
#9 10.95 AttributeError: module 'posixpath' has no attribute 'append'
#9 10.95 Attempting to compile the ref10 library...
#9 10.95 The compilation requires CMake and the "make" tool.
#9 10.95 The "cmake" and "make" commands are used.
#9 10.95 [end of output]
#9 10.95
#9 10.95 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 10.96 error: metadata-generation-failed
#9 10.96
#9 10.96 × Encountered error while generating package metadata.
#9 10.96 ╰─> See above for output.
#9 10.96
#9 10.96 note: This is an issue with the package mentioned above, not pip.
#9 10.96 hint: See above for details.
#9 10.96 WARNING: You are using pip version 22.0.4; however, version 22.3 is available.
#9 10.96 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
------
executor failed running [/bin/sh -c pip3 install -r requirements.txt]: exit code: 1
Внутри моего dockerfile я попытался обновить setuptools, но, видимо, проблема не в этом. Мой файл докера выглядит так (я новичок в докере):
FROM python:3.8-slim-buster
WORKDIR .
COPY requirements.txt requirements.txt
RUN pip3 install --upgrade setuptools
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python3", "./server.py"]
Требования.txt содержит только криптографию == 38.0.1 и xeddsa == 0.6.0.
Как я могу это исправить? У меня заканчиваются идеи.
РЕШЕНИЕ: Спасибо за помощь. Я следовал советам Спрамудиты. Вещи, которые я должен был установить, где: build-essential, cmake, компилятор protobuf и libsodium
No such file or directory: 'cmake'
— ключевая ошибка. Можете адаптировать, например, Как установить библиотеки, требующие компиляции, на google-colaboratory?
попробуйте это stackoverflow.com/a/55508937/202168
Это может быть очень неприятно, когда вы видите, что ваша сборка докера раз за разом заканчивается ошибкой. Что-то, что вы можете попробовать в будущем;
apt-get update && apt-get -y install cmake protobuf-compiler
как указано в комментарии @Anentropic
А иногда даже все это; apt-get update && apt-get install -y gfortran libfreetype6-dev libhdf5-dev liblapack-dev libopenblas-dev libpng-dev && rm -rf /var/lib/apt/lists/*
Обратите внимание на rm -rf /var/lib/apt/lists/*
, чтобы в докере не было ненужных вещей.Надеюсь это поможет!
«Для компиляции требуется CMake и инструмент make». ... вы убедились, что эти пакеты установлены в контейнере докера перед запуском установки pip?