如何使用先知1.0.1创建Docker Image

发布于 2025-01-27 07:19:35 字数 24248 浏览 5 评论 0原文

我正在尝试使用prophet库构建Docker映像

numpy==1.20.2
pandas==1.2.1
pystan==2.19.1.1
joblib==0.15.1
prophet==1.0.1
scikit-learn==0.24.1
hampel==0.0.5
google
google-cloud-secret-manager
tqdm

。使用以下Docker文件的命令,我的构建不会成功。这是我的docker文件 -

FROM python:3.7-slim-buster as base

COPY app /root/app
WORKDIR /root
RUN apt update
RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm
RUN pip3 install --upgrade pip


# Below method does not work and still gives no module named numpy error even though numpy is present in requirements.txt
RUN pip install --no-cache-dir -U -r ./app/requirements.txt

# CMD streamlit run app/app.py --server.maxUploadSize=512 --server.port 8080
ENTRYPOINT ["tail", "-f", "/dev/null"]

这是我使用此组合时的错误跟踪 -

#11 24.36   
#11 24.36   × python setup.py bdist_wheel did not run successfully.
#11 24.36   │ exit code: 1
#11 24.36   ╰─> [41 lines of output]
#11 24.36       running bdist_wheel
#11 24.36       running build
#11 24.36       running build_py
#11 24.36       creating build
#11 24.36       creating build/lib
#11 24.36       creating build/lib/prophet
#11 24.36       creating build/lib/prophet/stan_model
#11 24.36       Traceback (most recent call last):
#11 24.36         File "<string>", line 36, in <module>
#11 24.36         File "<pip-setuptools-caller>", line 34, in <module>
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/setup.py", line 150, in <module>
#11 24.36           long_description_content_type='text/markdown',
#11 24.36         File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup
#11 24.36           return distutils.core.setup(**attrs)
#11 24.36         File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
#11 24.36           dist.run_commands()
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
#11 24.36           self.run_command(cmd)
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
#11 24.36           cmd_obj.run()
#11 24.36         File "/usr/local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 299, in run
#11 24.36           self.run_command('build')
#11 24.36         File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
#11 24.36           self.distribution.run_command(command)
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
#11 24.36           cmd_obj.run()
#11 24.36         File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
#11 24.36           self.run_command(cmd_name)
#11 24.36         File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
#11 24.36           self.distribution.run_command(command)
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
#11 24.36           cmd_obj.run()
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/setup.py", line 48, in run
#11 24.36           build_models(target_dir)
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/setup.py", line 36, in build_models
#11 24.36           from prophet.models import StanBackendEnum
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/prophet/__init__.py", line 8, in <module>
#11 24.36           from prophet.forecaster import Prophet
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/prophet/forecaster.py", line 14, in <module>
#11 24.36           import numpy as np
#11 24.36       ModuleNotFoundError: No module named 'numpy'

因此,我尝试在Docker文件本身中添加依赖项以查看和测试这些依赖项 -

在我的试验2中,我的Docker文件看起来像这样 -

FROM python:3.7-slim-buster as base

COPY app /root/app
WORKDIR /root
RUN apt update
RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm
RUN pip3 install --upgrade pip

RUN pip install numpy==1.21.0
RUN pip install pandas==1.2.1
RUN pip install pystan==2.19.1.1
RUN pip install convertdate
RUN pip install lunarcalendar
RUN pip install holidays
RUN pip install tqdm
RUN pip install prophet==1.0.1



# CMD streamlit run app/app.py --server.maxUploadSize=512 --server.port 8080
ENTRYPOINT ["tail", "-f", "/dev/null"]

然后我做了docker build。,这一次我得到的错误跟踪 -

[+] Building 89.3s (17/18)                                                                                                                                       
 => [internal] load metadata for docker.io/library/python:3.7-slim-buster                                                                                   0.8s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 65B                                                                                                                            0.0s
 => [ 1/14] FROM docker.io/library/python:3.7-slim-buster@sha256:1c99a3b0f4c8168b2210e74911cbcf028a6a44ddad50d0eed5a5eced28173295                           0.0s
 => CACHED [ 2/14] COPY app /root/app                                                                                                                       0.0s
 => CACHED [ 3/14] WORKDIR /root                                                                                                                            0.0s
 => CACHED [ 4/14] RUN apt update                                                                                                                           0.0s
 => CACHED [ 5/14] RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm                                 0.0s
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s
[+] Building 89.4s (17/18)                                                                                                                                       
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s 
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s 
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s 
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s 
 => [11/14] RUN pip install lunarcalendar                                                                                                                   3.0s 
 => [12/14] RUN pip install holidays                                                                                                                        3.1s 
 => [13/14] RUN pip install tqdm                                                                                                                            1.7s 
 => [14/14] RUN pip install prophet==1.0.1                                                                                                                 41.2s 
                                                                                                                                                                 
                                                                                                                                                                 
                                                                                                                                                                 
                                                                                                                                                                 
[+] Building 732.3s (17/18)                                                                                                                                      
 => [internal] load build definition from Dockerfile                                                                                                        0.0s 
 => => transferring dockerfile: 911B                                                                                                                        0.0s 
 => [internal] load .dockerignore                                                                                                                           0.0s 
 => => transferring context: 2B                                                                                                                             0.0s 
 => [internal] load metadata for docker.io/library/python:3.7-slim-buster                                                                                   0.8s 
 => [internal] load build context                                                                                                                           0.0s 
 => => transferring context: 65B                                                                                                                            0.0s 
 => [ 1/14] FROM docker.io/library/python:3.7-slim-buster@sha256:1c99a3b0f4c8168b2210e74911cbcf028a6a44ddad50d0eed5a5eced28173295                           0.0s 
 => CACHED [ 2/14] COPY app /root/app                                                                                                                       0.0s 
[+] Building 732.5s (17/18)                                                                                                                                      
 => CACHED [ 4/14] RUN apt update                                                                                                                           0.0s
 => CACHED [ 5/14] RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm                                 0.0s
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s
 => [11/14] RUN pip install lunarcalendar                                                                                                                   3.0s
 => [12/14] RUN pip install holidays                                                                                                                        3.1s
[+] Building 1015.7s (18/18) FINISHED                                                                                                                            
 => [internal] load build definition from Dockerfile                                                                                                        0.0s
 => => transferring dockerfile: 911B                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/python:3.7-slim-buster                                                                                   0.8s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 65B                                                                                                                            0.0s
 => [ 1/14] FROM docker.io/library/python:3.7-slim-buster@sha256:1c99a3b0f4c8168b2210e74911cbcf028a6a44ddad50d0eed5a5eced28173295                           0.0s 
 => CACHED [ 2/14] COPY app /root/app                                                                                                                       0.0s 
 => CACHED [ 3/14] WORKDIR /root                                                                                                                            0.0s 
 => CACHED [ 4/14] RUN apt update                                                                                                                           0.0s 
 => CACHED [ 5/14] RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm                                 0.0s 
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s 
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s 
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s 
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s 
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s 
 => [11/14] RUN pip install lunarcalendar                                                                                                                   3.0s
 => [12/14] RUN pip install holidays                                                                                                                        3.1s
 => [13/14] RUN pip install tqdm                                                                                                                            1.7s
 => ERROR [14/14] RUN pip install prophet==1.0.1                                                                                                          967.4s
------                                                                                                                                                           
 > [14/14] RUN pip install prophet==1.0.1:                                                                                                                       
#18 0.996 Collecting prophet==1.0.1                                                                                                                              
#18 1.125   Downloading prophet-1.0.1.tar.gz (65 kB)                                                                                                             
#18 1.153      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.8/65.8 KB 3.2 MB/s eta 0:00:00                                                                        
#18 1.176   Preparing metadata (setup.py): started                                                                                                               
#18 1.513   Preparing metadata (setup.py): finished with status 'done'
#18 1.528 Requirement already satisfied: Cython>=0.22 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (0.29.28)
#18 1.752 Collecting cmdstanpy==0.9.68
#18 1.853   Downloading cmdstanpy-0.9.68-py3-none-any.whl (49 kB)
#18 1.876      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.0/49.0 KB 2.5 MB/s eta 0:00:00
#18 1.880 Requirement already satisfied: pystan~=2.19.1.1 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (2.19.1.1)
#18 1.881 Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (1.21.0)
#18 1.883 Requirement already satisfied: pandas>=1.0.4 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (1.2.1)
#18 2.119 Collecting matplotlib>=2.0.0
#18 2.146   Downloading matplotlib-3.5.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.2 MB)
#18 3.265      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.2/11.2 MB 18.3 MB/s eta 0:00:00
#18 3.323 Requirement already satisfied: LunarCalendar>=0.0.9 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (0.0.9)
#18 3.324 Requirement already satisfied: convertdate>=2.1.2 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (2.4.0)
#18 3.326 Requirement already satisfied: holidays>=0.10.2 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (0.13)
#18 3.371 Collecting setuptools-git>=1.2
#18 3.436   Downloading setuptools_git-1.2-py2.py3-none-any.whl (10 kB)
#18 3.453 Requirement already satisfied: python-dateutil>=2.8.0 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (2.8.2)
#18 3.456 Requirement already satisfied: tqdm>=4.36.1 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (4.64.0)
#18 3.612 Collecting ujson
#18 3.669   Downloading ujson-5.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (45 kB)
#18 3.693      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.0/45.0 KB 2.1 MB/s eta 0:00:00
#18 3.713 Requirement already satisfied: pymeeus<=1,>=0.3.13 in /usr/local/lib/python3.7/site-packages (from convertdate>=2.1.2->prophet==1.0.1) (0.5.11)
#18 3.719 Requirement already satisfied: korean-lunar-calendar in /usr/local/lib/python3.7/site-packages (from holidays>=0.10.2->prophet==1.0.1) (0.2.1)
#18 3.720 Requirement already satisfied: hijri-converter in /usr/local/lib/python3.7/site-packages (from holidays>=0.10.2->prophet==1.0.1) (2.2.3)
#18 3.726 Requirement already satisfied: pytz in /usr/local/lib/python3.7/site-packages (from LunarCalendar>=0.0.9->prophet==1.0.1) (2022.1)
#18 3.727 Requirement already satisfied: ephem>=3.7.5.3 in /usr/local/lib/python3.7/site-packages (from LunarCalendar>=0.0.9->prophet==1.0.1) (4.1.3)
#18 3.773 Collecting cycler>=0.10
#18 3.791   Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)
#18 4.149 Collecting pillow>=6.2.0
#18 4.202   Downloading Pillow-9.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
#18 4.459      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 17.2 MB/s eta 0:00:00
#18 4.891 Collecting fonttools>=4.22.0
#18 4.929   Downloading fonttools-4.33.3-py3-none-any.whl (930 kB)
#18 4.981      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 930.9/930.9 KB 19.7 MB/s eta 0:00:00
#18 5.171 Collecting pyparsing>=2.2.1
#18 5.191   Downloading pyparsing-3.0.8-py3-none-any.whl (98 kB)
#18 5.208      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.5/98.5 KB 10.2 MB/s eta 0:00:00
#18 5.562 Collecting packaging>=20.0
#18 5.585   Downloading packaging-21.3-py3-none-any.whl (40 kB)
#18 5.594      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 KB 6.7 MB/s eta 0:00:00
#18 5.908 Collecting kiwisolver>=1.0.1
#18 5.970   Downloading kiwisolver-1.4.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB)
#18 6.111      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 8.9 MB/s eta 0:00:00
#18 6.135 Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil>=2.8.0->prophet==1.0.1) (1.16.0)
#18 6.289 Collecting typing-extensions
#18 6.305   Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB)
#18 6.389 Building wheels for collected packages: prophet
#18 6.391   Building wheel for prophet (setup.py): started
#18 282.2   Building wheel for prophet (setup.py): still running...
#18 287.9   Building wheel for prophet (setup.py): finished with status 'error'
#18 288.4   error: subprocess-exited-with-error
#18 288.4   
#18 288.4   × python setup.py bdist_wheel did not run successfully.
#18 288.4   │ exit code: 1
#18 288.4   ╰─> [11 lines of output]
#18 288.4       running bdist_wheel
#18 288.4       running build
#18 288.4       running build_py
#18 288.4       creating build
#18 288.4       creating build/lib
#18 288.4       creating build/lib/prophet
#18 288.4       creating build/lib/prophet/stan_model
#18 288.4       Importing matplotlib failed. Plotting will not work.
#18 288.4       Importing plotly failed. Interactive plots will not work.
#18 288.4       INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
#18 288.4       error: command 'gcc' failed with exit status 1
#18 288.4       [end of output]
#18 288.4   
#18 288.4   note: This error originates from a subprocess, and is likely not a problem with pip.
#18 288.4   ERROR: Failed building wheel for prophet
#18 288.4   Running setup.py clean for prophet
#18 289.1 Failed to build prophet
#18 289.7 Installing collected packages: setuptools-git, ujson, typing-extensions, pyparsing, pillow, fonttools, cycler, packaging, kiwisolver, matplotlib, cmdstanpy, prophet
#18 293.9   Running setup.py install for prophet: started
#18 959.4   Running setup.py install for prophet: still running...
#18 964.5   Running setup.py install for prophet: finished with status 'error'
#18 964.7   error: subprocess-exited-with-error
#18 964.7   
#18 964.7   × Running setup.py install for prophet did not run successfully.
#18 964.7   │ exit code: 1
#18 964.7   ╰─> [10 lines of output]
#18 964.7       running install
#18 964.7       running build
#18 964.7       running build_py
#18 964.7       creating build
#18 964.7       creating build/lib
#18 964.7       creating build/lib/prophet
#18 964.7       creating build/lib/prophet/stan_model
#18 964.7       Importing plotly failed. Interactive plots will not work.
#18 964.7       INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
#18 964.7       error: command 'gcc' failed with exit status 1
#18 964.7       [end of output]
#18 964.7   
#18 964.7   note: This error originates from a subprocess, and is likely not a problem with pip.
#18 964.9 error: legacy-install-failure
#18 964.9 
#18 964.9 × Encountered error while trying to install package.
#18 964.9 ╰─> prophet
#18 964.9 
#18 964.9 note: This is an issue with the package mentioned above, not pip.
#18 964.9 hint: See above for output from the failure.

在试验2中,我看不到特定的错误,但我的构建仍然失败。

有没有人尝试使用先知图书馆构建干净的图像?

I am trying to build a docker image with prophet library and in my requirements.txt I have called out for all the dependencies as below -

numpy==1.20.2
pandas==1.2.1
pystan==2.19.1.1
joblib==0.15.1
prophet==1.0.1
scikit-learn==0.24.1
hampel==0.0.5
google
google-cloud-secret-manager
tqdm

Yet, when I run docker build . command using the below docker file , my build does not go successful. Here is my docker file -

FROM python:3.7-slim-buster as base

COPY app /root/app
WORKDIR /root
RUN apt update
RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm
RUN pip3 install --upgrade pip


# Below method does not work and still gives no module named numpy error even though numpy is present in requirements.txt
RUN pip install --no-cache-dir -U -r ./app/requirements.txt

# CMD streamlit run app/app.py --server.maxUploadSize=512 --server.port 8080
ENTRYPOINT ["tail", "-f", "/dev/null"]

Here is the error trace when I use this combination -

#11 24.36   
#11 24.36   × python setup.py bdist_wheel did not run successfully.
#11 24.36   │ exit code: 1
#11 24.36   ╰─> [41 lines of output]
#11 24.36       running bdist_wheel
#11 24.36       running build
#11 24.36       running build_py
#11 24.36       creating build
#11 24.36       creating build/lib
#11 24.36       creating build/lib/prophet
#11 24.36       creating build/lib/prophet/stan_model
#11 24.36       Traceback (most recent call last):
#11 24.36         File "<string>", line 36, in <module>
#11 24.36         File "<pip-setuptools-caller>", line 34, in <module>
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/setup.py", line 150, in <module>
#11 24.36           long_description_content_type='text/markdown',
#11 24.36         File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup
#11 24.36           return distutils.core.setup(**attrs)
#11 24.36         File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
#11 24.36           dist.run_commands()
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
#11 24.36           self.run_command(cmd)
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
#11 24.36           cmd_obj.run()
#11 24.36         File "/usr/local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 299, in run
#11 24.36           self.run_command('build')
#11 24.36         File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
#11 24.36           self.distribution.run_command(command)
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
#11 24.36           cmd_obj.run()
#11 24.36         File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
#11 24.36           self.run_command(cmd_name)
#11 24.36         File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
#11 24.36           self.distribution.run_command(command)
#11 24.36         File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
#11 24.36           cmd_obj.run()
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/setup.py", line 48, in run
#11 24.36           build_models(target_dir)
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/setup.py", line 36, in build_models
#11 24.36           from prophet.models import StanBackendEnum
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/prophet/__init__.py", line 8, in <module>
#11 24.36           from prophet.forecaster import Prophet
#11 24.36         File "/tmp/pip-install-_y2f8_xf/prophet_6675cc9554e243a9ad11808d577194a8/prophet/forecaster.py", line 14, in <module>
#11 24.36           import numpy as np
#11 24.36       ModuleNotFoundError: No module named 'numpy'

So then, I tried adding the dependencies in the docker file itself to see and test out these dependencies -

In my trial 2, my docker file looks like this -

FROM python:3.7-slim-buster as base

COPY app /root/app
WORKDIR /root
RUN apt update
RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm
RUN pip3 install --upgrade pip

RUN pip install numpy==1.21.0
RUN pip install pandas==1.2.1
RUN pip install pystan==2.19.1.1
RUN pip install convertdate
RUN pip install lunarcalendar
RUN pip install holidays
RUN pip install tqdm
RUN pip install prophet==1.0.1



# CMD streamlit run app/app.py --server.maxUploadSize=512 --server.port 8080
ENTRYPOINT ["tail", "-f", "/dev/null"]

Then I did docker build . and this time I got below error trace -

[+] Building 89.3s (17/18)                                                                                                                                       
 => [internal] load metadata for docker.io/library/python:3.7-slim-buster                                                                                   0.8s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 65B                                                                                                                            0.0s
 => [ 1/14] FROM docker.io/library/python:3.7-slim-buster@sha256:1c99a3b0f4c8168b2210e74911cbcf028a6a44ddad50d0eed5a5eced28173295                           0.0s
 => CACHED [ 2/14] COPY app /root/app                                                                                                                       0.0s
 => CACHED [ 3/14] WORKDIR /root                                                                                                                            0.0s
 => CACHED [ 4/14] RUN apt update                                                                                                                           0.0s
 => CACHED [ 5/14] RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm                                 0.0s
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s
[+] Building 89.4s (17/18)                                                                                                                                       
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s 
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s 
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s 
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s 
 => [11/14] RUN pip install lunarcalendar                                                                                                                   3.0s 
 => [12/14] RUN pip install holidays                                                                                                                        3.1s 
 => [13/14] RUN pip install tqdm                                                                                                                            1.7s 
 => [14/14] RUN pip install prophet==1.0.1                                                                                                                 41.2s 
                                                                                                                                                                 
                                                                                                                                                                 
                                                                                                                                                                 
                                                                                                                                                                 
[+] Building 732.3s (17/18)                                                                                                                                      
 => [internal] load build definition from Dockerfile                                                                                                        0.0s 
 => => transferring dockerfile: 911B                                                                                                                        0.0s 
 => [internal] load .dockerignore                                                                                                                           0.0s 
 => => transferring context: 2B                                                                                                                             0.0s 
 => [internal] load metadata for docker.io/library/python:3.7-slim-buster                                                                                   0.8s 
 => [internal] load build context                                                                                                                           0.0s 
 => => transferring context: 65B                                                                                                                            0.0s 
 => [ 1/14] FROM docker.io/library/python:3.7-slim-buster@sha256:1c99a3b0f4c8168b2210e74911cbcf028a6a44ddad50d0eed5a5eced28173295                           0.0s 
 => CACHED [ 2/14] COPY app /root/app                                                                                                                       0.0s 
[+] Building 732.5s (17/18)                                                                                                                                      
 => CACHED [ 4/14] RUN apt update                                                                                                                           0.0s
 => CACHED [ 5/14] RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm                                 0.0s
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s
 => [11/14] RUN pip install lunarcalendar                                                                                                                   3.0s
 => [12/14] RUN pip install holidays                                                                                                                        3.1s
[+] Building 1015.7s (18/18) FINISHED                                                                                                                            
 => [internal] load build definition from Dockerfile                                                                                                        0.0s
 => => transferring dockerfile: 911B                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/python:3.7-slim-buster                                                                                   0.8s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 65B                                                                                                                            0.0s
 => [ 1/14] FROM docker.io/library/python:3.7-slim-buster@sha256:1c99a3b0f4c8168b2210e74911cbcf028a6a44ddad50d0eed5a5eced28173295                           0.0s 
 => CACHED [ 2/14] COPY app /root/app                                                                                                                       0.0s 
 => CACHED [ 3/14] WORKDIR /root                                                                                                                            0.0s 
 => CACHED [ 4/14] RUN apt update                                                                                                                           0.0s 
 => CACHED [ 5/14] RUN apt-get install -y --no-install-recommends g++ build-essential git python3-dev gcc libc-dev wget rpm                                 0.0s 
 => CACHED [ 6/14] RUN pip3 install --upgrade pip                                                                                                           0.0s 
 => [ 7/14] RUN pip install numpy==1.21.0                                                                                                                   6.5s 
 => [ 8/14] RUN pip install pandas==1.2.1                                                                                                                   6.3s 
 => [ 9/14] RUN pip install pystan==2.19.1.1                                                                                                               19.4s 
 => [10/14] RUN pip install convertdate                                                                                                                     7.2s 
 => [11/14] RUN pip install lunarcalendar                                                                                                                   3.0s
 => [12/14] RUN pip install holidays                                                                                                                        3.1s
 => [13/14] RUN pip install tqdm                                                                                                                            1.7s
 => ERROR [14/14] RUN pip install prophet==1.0.1                                                                                                          967.4s
------                                                                                                                                                           
 > [14/14] RUN pip install prophet==1.0.1:                                                                                                                       
#18 0.996 Collecting prophet==1.0.1                                                                                                                              
#18 1.125   Downloading prophet-1.0.1.tar.gz (65 kB)                                                                                                             
#18 1.153      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.8/65.8 KB 3.2 MB/s eta 0:00:00                                                                        
#18 1.176   Preparing metadata (setup.py): started                                                                                                               
#18 1.513   Preparing metadata (setup.py): finished with status 'done'
#18 1.528 Requirement already satisfied: Cython>=0.22 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (0.29.28)
#18 1.752 Collecting cmdstanpy==0.9.68
#18 1.853   Downloading cmdstanpy-0.9.68-py3-none-any.whl (49 kB)
#18 1.876      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.0/49.0 KB 2.5 MB/s eta 0:00:00
#18 1.880 Requirement already satisfied: pystan~=2.19.1.1 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (2.19.1.1)
#18 1.881 Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (1.21.0)
#18 1.883 Requirement already satisfied: pandas>=1.0.4 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (1.2.1)
#18 2.119 Collecting matplotlib>=2.0.0
#18 2.146   Downloading matplotlib-3.5.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.2 MB)
#18 3.265      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.2/11.2 MB 18.3 MB/s eta 0:00:00
#18 3.323 Requirement already satisfied: LunarCalendar>=0.0.9 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (0.0.9)
#18 3.324 Requirement already satisfied: convertdate>=2.1.2 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (2.4.0)
#18 3.326 Requirement already satisfied: holidays>=0.10.2 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (0.13)
#18 3.371 Collecting setuptools-git>=1.2
#18 3.436   Downloading setuptools_git-1.2-py2.py3-none-any.whl (10 kB)
#18 3.453 Requirement already satisfied: python-dateutil>=2.8.0 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (2.8.2)
#18 3.456 Requirement already satisfied: tqdm>=4.36.1 in /usr/local/lib/python3.7/site-packages (from prophet==1.0.1) (4.64.0)
#18 3.612 Collecting ujson
#18 3.669   Downloading ujson-5.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (45 kB)
#18 3.693      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.0/45.0 KB 2.1 MB/s eta 0:00:00
#18 3.713 Requirement already satisfied: pymeeus<=1,>=0.3.13 in /usr/local/lib/python3.7/site-packages (from convertdate>=2.1.2->prophet==1.0.1) (0.5.11)
#18 3.719 Requirement already satisfied: korean-lunar-calendar in /usr/local/lib/python3.7/site-packages (from holidays>=0.10.2->prophet==1.0.1) (0.2.1)
#18 3.720 Requirement already satisfied: hijri-converter in /usr/local/lib/python3.7/site-packages (from holidays>=0.10.2->prophet==1.0.1) (2.2.3)
#18 3.726 Requirement already satisfied: pytz in /usr/local/lib/python3.7/site-packages (from LunarCalendar>=0.0.9->prophet==1.0.1) (2022.1)
#18 3.727 Requirement already satisfied: ephem>=3.7.5.3 in /usr/local/lib/python3.7/site-packages (from LunarCalendar>=0.0.9->prophet==1.0.1) (4.1.3)
#18 3.773 Collecting cycler>=0.10
#18 3.791   Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)
#18 4.149 Collecting pillow>=6.2.0
#18 4.202   Downloading Pillow-9.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
#18 4.459      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 17.2 MB/s eta 0:00:00
#18 4.891 Collecting fonttools>=4.22.0
#18 4.929   Downloading fonttools-4.33.3-py3-none-any.whl (930 kB)
#18 4.981      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 930.9/930.9 KB 19.7 MB/s eta 0:00:00
#18 5.171 Collecting pyparsing>=2.2.1
#18 5.191   Downloading pyparsing-3.0.8-py3-none-any.whl (98 kB)
#18 5.208      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.5/98.5 KB 10.2 MB/s eta 0:00:00
#18 5.562 Collecting packaging>=20.0
#18 5.585   Downloading packaging-21.3-py3-none-any.whl (40 kB)
#18 5.594      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 KB 6.7 MB/s eta 0:00:00
#18 5.908 Collecting kiwisolver>=1.0.1
#18 5.970   Downloading kiwisolver-1.4.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB)
#18 6.111      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 8.9 MB/s eta 0:00:00
#18 6.135 Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil>=2.8.0->prophet==1.0.1) (1.16.0)
#18 6.289 Collecting typing-extensions
#18 6.305   Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB)
#18 6.389 Building wheels for collected packages: prophet
#18 6.391   Building wheel for prophet (setup.py): started
#18 282.2   Building wheel for prophet (setup.py): still running...
#18 287.9   Building wheel for prophet (setup.py): finished with status 'error'
#18 288.4   error: subprocess-exited-with-error
#18 288.4   
#18 288.4   × python setup.py bdist_wheel did not run successfully.
#18 288.4   │ exit code: 1
#18 288.4   ╰─> [11 lines of output]
#18 288.4       running bdist_wheel
#18 288.4       running build
#18 288.4       running build_py
#18 288.4       creating build
#18 288.4       creating build/lib
#18 288.4       creating build/lib/prophet
#18 288.4       creating build/lib/prophet/stan_model
#18 288.4       Importing matplotlib failed. Plotting will not work.
#18 288.4       Importing plotly failed. Interactive plots will not work.
#18 288.4       INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
#18 288.4       error: command 'gcc' failed with exit status 1
#18 288.4       [end of output]
#18 288.4   
#18 288.4   note: This error originates from a subprocess, and is likely not a problem with pip.
#18 288.4   ERROR: Failed building wheel for prophet
#18 288.4   Running setup.py clean for prophet
#18 289.1 Failed to build prophet
#18 289.7 Installing collected packages: setuptools-git, ujson, typing-extensions, pyparsing, pillow, fonttools, cycler, packaging, kiwisolver, matplotlib, cmdstanpy, prophet
#18 293.9   Running setup.py install for prophet: started
#18 959.4   Running setup.py install for prophet: still running...
#18 964.5   Running setup.py install for prophet: finished with status 'error'
#18 964.7   error: subprocess-exited-with-error
#18 964.7   
#18 964.7   × Running setup.py install for prophet did not run successfully.
#18 964.7   │ exit code: 1
#18 964.7   ╰─> [10 lines of output]
#18 964.7       running install
#18 964.7       running build
#18 964.7       running build_py
#18 964.7       creating build
#18 964.7       creating build/lib
#18 964.7       creating build/lib/prophet
#18 964.7       creating build/lib/prophet/stan_model
#18 964.7       Importing plotly failed. Interactive plots will not work.
#18 964.7       INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
#18 964.7       error: command 'gcc' failed with exit status 1
#18 964.7       [end of output]
#18 964.7   
#18 964.7   note: This error originates from a subprocess, and is likely not a problem with pip.
#18 964.9 error: legacy-install-failure
#18 964.9 
#18 964.9 × Encountered error while trying to install package.
#18 964.9 ╰─> prophet
#18 964.9 
#18 964.9 note: This is an issue with the package mentioned above, not pip.
#18 964.9 hint: See above for output from the failure.

In trial 2, I do not see specific errors but my build still fails.

Has anyone tried building a clean image with prophet library ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半世晨晓 2025-02-03 07:19:35

我搜索了很长时间并找到一些解决方案...我用作基础:

partial Solution

FROM python:3.9-slim

# we probably need build tools?
RUN apt-get update \
    && apt-get install --yes --no-install-recommends \
    build-essential

# we need the requirements.txt file from prophet to be in the root of the project
# https://github.com/facebook/prophet/blob/main/python/requirements.txt
# WORKDIR /app
WORKDIR /home/node/app2
COPY . .

# first: install all required packages for pystan
RUN pip install --no-cache-dir --upgrade cython numpy
# second: install all required packages for prophet from their requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# third: install prophet itself
RUN pip install --no-cache-dir --upgrade prophet

RUN pip install -U Flask

RUN pip install -U flask-cors

RUN pip install  --upgrade plotly
# RUN pip install prophet



# WORKDIR /home/node/app2

RUN python finally.py
ENTRYPOINT ["tail", "-f", "/dev/null"]

noreferrer最后,对我的项目进行实施...我将使用它来进行另一个...现在只能使此操作...所以...我的代码不是“干净的代码”。

查看我在github上的我的projet

添加:

如果您对docker有问题,也许是一个可能的解决方案:一个可能的解决方案:
1-删除所有容器:Docker RM -VF $(Docker PS -AQ)
之后
2-删除所有成像:Docker RMI -F $(Docker Images -AQ)

另一种方法:
有时您需要多次尝试运行docker-compose-build
是的,也许服务器下降了...有一些问题或等。这很常见
倍数阶段。这是一个痛苦...

观察:“ 4个月前” ...也许有人也需要这个...

I search this for a long time and find some solutions... I use as a base:

Partial Solution

And

Use case without DockerFile

FROM python:3.9-slim

# we probably need build tools?
RUN apt-get update \
    && apt-get install --yes --no-install-recommends \
    build-essential

# we need the requirements.txt file from prophet to be in the root of the project
# https://github.com/facebook/prophet/blob/main/python/requirements.txt
# WORKDIR /app
WORKDIR /home/node/app2
COPY . .

# first: install all required packages for pystan
RUN pip install --no-cache-dir --upgrade cython numpy
# second: install all required packages for prophet from their requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# third: install prophet itself
RUN pip install --no-cache-dir --upgrade prophet

RUN pip install -U Flask

RUN pip install -U flask-cors

RUN pip install  --upgrade plotly
# RUN pip install prophet



# WORKDIR /home/node/app2

RUN python finally.py
ENTRYPOINT ["tail", "-f", "/dev/null"]

And finally make a implementation on my project... i will use this for another one... only make this works now... so... my code ins't the "clean code".

Look at my projet on github

add:

If you have a problem with Docker maybe a possible solution:
1- Delete all containers: docker rm -vf $(docker ps -aq)
and after that
2- Delete all imagens: docker rmi -f $(docker images -aq)

Another way:
Some times you need to try multiple times run docker-compose up --build,
yes maybe the server is down... have some problems or etc. This is common in
multiples stages of the instalation. This is a pain...

obs: "4 months ago"... maybe someone need this too...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文