Я пытаюсь создать образ докера с Prophet 1.0.1.
Вот мой файл requirements.txt
google-cloud-bigquery
google-cloud-storage
numpy==1.21.0
pandas==1.2.0
db-dtypes
plotly==5.10.0
hampel==0.0.5
prophet==1.0.1
click
joblib
scikit-learn
а вот мой файл докера -
FROM python:3.8-slim-buster as base
RUN mkdir my_dir
COPY requirements.txt /my_dir/requirements.txt
COPY src /my_dir/src
WORKDIR /my_dir
RUN apt update
RUN apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
build-essential \
gcc \
g++ \
git \
curl \
apt-transport-https \
ca-certificates \
gnupg
RUN python -m pip install --no-cache-dir --upgrade setuptools pip wheel pipenv
RUN pip install -r requirements.txt
WORKDIR /my_dir/src
RUN python setup.py bdist_wheel
RUN pip install dist/*
# kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin
ENTRYPOINT [ "sh", "run.sh" ]
Когда я пытаюсь запустить команду docker-compose up -d
, локальная сборка завершается с ошибкой ниже:
13 25.10 Building wheels for collected packages: prophet, pymeeus
#13 25.10 Building wheel for prophet (setup.py): started
#13 25.40 Building wheel for prophet (setup.py): finished with status 'error'
#13 25.41 error: subprocess-exited-with-error
#13 25.41
#13 25.41 × python setup.py bdist_wheel did not run successfully.
#13 25.41 │ exit code: 1
#13 25.41 ╰─> [49 lines of output]
#13 25.41 running bdist_wheel
#13 25.41 running build
#13 25.41 running build_py
#13 25.41 creating build
#13 25.41 creating build/lib
#13 25.41 creating build/lib/prophet
#13 25.41 creating build/lib/prophet/stan_model
#13 25.41 Traceback (most recent call last):
#13 25.41 File "<string>", line 36, in <module>
#13 25.41 File "<pip-setuptools-caller>", line 34, in <module>
#13 25.41 File "/tmp/pip-install-l_l1ynvx/prophet_2f0894fc2ee74edfa49399ff3fb20863/setup.py", line 150, in <module>
#13 25.41 long_description_content_type='text/markdown',
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 108, in setup
#13 25.41 return distutils.core.setup(**attrs)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup
#13 25.41 return run_commands(dist)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
#13 25.41 dist.run_commands()
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
#13 25.41 self.run_command(cmd)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 1221, in run_command
#13 25.41 super().run_command(command)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
#13 25.41 cmd_obj.run()
#13 25.41 File "/usr/local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 343, in run
#13 25.41 self.run_command("build")
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
#13 25.41 self.distribution.run_command(command)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 1221, in run_command
#13 25.41 super().run_command(command)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
#13 25.41 cmd_obj.run()
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/command/build.py", line 131, in run
#13 25.41 self.run_command(cmd_name)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
#13 25.41 self.distribution.run_command(command)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 1221, in run_command
#13 25.41 super().run_command(command)
#13 25.41 File "/usr/local/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
#13 25.41 cmd_obj.run()
#13 25.41 File "/tmp/pip-install-l_l1ynvx/prophet_2f0894fc2ee74edfa49399ff3fb20863/setup.py", line 48, in run
#13 25.41 build_models(target_dir)
#13 25.41 File "/tmp/pip-install-l_l1ynvx/prophet_2f0894fc2ee74edfa49399ff3fb20863/setup.py", line 36, in build_models
#13 25.41 from prophet.models import StanBackendEnum
#13 25.41 File "/tmp/pip-install-l_l1ynvx/prophet_2f0894fc2ee74edfa49399ff3fb20863/prophet/__init__.py", line 8, in <module>
#13 25.41 from prophet.forecaster import Prophet
#13 25.41 File "/tmp/pip-install-l_l1ynvx/prophet_2f0894fc2ee74edfa49399ff3fb20863/prophet/forecaster.py", line 14, in <module>
#13 25.41 import numpy as np
#13 25.41 ModuleNotFoundError: No module named 'numpy'
#13 25.41 [end of output]
У меня есть пакет numpy
, включенный в requirements.txt
, но он мне не подходит. Как я могу успешно установить пророка 1.0.1 с помощью докера?
Prophet 1.0.1, похоже, нуждается в некоторых своих зависимостях, прежде чем пакет можно будет собрать, поэтому вам нужно сначала установить их. Вы можете изменить свой requirements.txt
на
google-cloud-bigquery
google-cloud-storage
numpy==1.21.0
pandas==1.2.0
db-dtypes
plotly==5.10.0
hampel==0.0.5
click
joblib
scikit-learn
pystan==2.19.1.1
Cython
cmdstanpy==0.9.68
matplotlib
LunarCalendar
convertdate
holidays
setuptools-git
python-dateutil
tqdm
(Обратите внимание, что prophet==1.0.1
был удален здесь.) А затем измените свой Dockerfile
на
FROM python:3.8-slim-buster as base
RUN mkdir my_dir
COPY src /my_dir/src
WORKDIR /my_dir
RUN apt update
RUN apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
build-essential \
gcc \
g++ \
git \
curl \
apt-transport-https \
ca-certificates \
gnupg
COPY requirements.txt /my_dir/requirements.txt
RUN python -m pip install --no-cache-dir --upgrade setuptools pip wheel pipenv
RUN pip install -r requirements.txt
RUN pip install prophet==1.0.1
WORKDIR /my_dir/src
RUN python setup.py bdist_wheel
RUN pip install dist/*
# kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin
ENTRYPOINT [ "sh", "run.sh" ]
Кроме того, вы можете переключиться на более новую версию пророка, в которой нет этой проблемы.
это работает, если вы установите
numpy
раньше?