如果我在容器中运行pythonscript,它将在没有任何问题的情况下运行。但是,当我将其作为cronjob运行时,它抛出一个错误,即未找到任何模块。你有什么想法吗?
dockerfile
Sub QualifyCellsToo()
Dim wsSource As Worksheet: Set wsSource = ThisWorkbook.Worksheets("Sheet1")
Dim wsTarget As Worksheet: Set wsTarget = ThisWorkbook.Worksheets("Sheet2")
Dim rngSource As Range
Dim rngTarget As Range
' This is wrong:
'Worksheets("sheets1").Range(Cells(3, 4), Cells(3, 9)).Copy _
Worksheets("sheets2").Range(Cells(3, 4), Cells(3, 9))
' You have to qualify 'Cells', too:
Worksheets("Sheet1").Range(Worksheets("Sheet1").Cells(3, 4), _
Worksheets("Sheet1").Cells(3, 9)).Copy _
Worksheets("Sheet2").Range(Worksheets("Sheet2").Cells(3, 4), _
Worksheets("Sheet2").Cells(3, 9))
' This is a long expression, so using variables is preferred.
Set rngSource = wsSource.Range(wsSource.Cells(3, 4), wsSource.Cells(3, 9))
Set rngTarget = wsTarget.Range(wsTarget.Cells(3, 4), wsTarget.Cells(3, 9))
Set rngTarget = rngTarget.Offset(1)
rngTarget.Resize(10).Clear
' Copy values or formulas and formats using same sized ranges.
rngSource.Copy rngTarget
Set rngTarget = rngTarget.Offset(1)
' Copy values or formulas and formats using only the first cell
' of Target Range.
rngSource.Copy rngTarget.Cells(1)
Set rngTarget = rngTarget.Offset(1)
' Copy values
rngTarget.Value = rngSource.Value
Set rngTarget = rngTarget.Offset(1)
' Copy values using target without '.Value'
rngTarget = rngSource.Value
Set rngTarget = rngTarget.Offset(1)
End Sub
cronpy
FROM python:3.5.2
RUN apt-get update \
&& apt-get install -y cron \
&& apt-get autoremove -y
RUN pip install --upgrade pip && \
pip install --no-cache-dir image pytesseract numpy XlsxWriter pandas requests && \
pip install --no-cache-dir med2image datetime IPython matplotlib
# Create a volume
VOLUME /logSent
# Copy Scriptfile
COPY script.py ./script.py
# Copy cron file to the cron.d directory
COPY cronpy /etc/cron.d/cronpy
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cronpy
# Apply cron job
RUN crontab /etc/cron.d/cronpy
CMD ["cron", "-f"]
答案 0 :(得分:0)
尝试在cronpy
中使用python的绝对路径,例如
*/10 * * * * /usr/bin/python /script.py > /proc/1/fd/1 2>/proc/1/fd/2
答案 1 :(得分:0)
好的,当我使用ubuntu映像并自己安装python而不是它正常运行的python映像时。