Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker for Debian Python3.9-slim #253

Open
pasha76 opened this issue Jul 7, 2023 · 1 comment
Open

Docker for Debian Python3.9-slim #253

pasha76 opened this issue Jul 7, 2023 · 1 comment

Comments

@pasha76
Copy link

pasha76 commented Jul 7, 2023

ImageMagick version

6

Operating system

Linux

Operating system, version and so on

Debian

Description

I am trying to create a video with moviepy and below is the dockerfile.

Use an official Python runtime as a parent image

FROM python:3.9-slim

Set the working directory in the container to /app

WORKDIR /app

Add the current directory contents into the container at /app

ADD . /app

Install required libraries for moviepy

RUN apt-get update && apt-get install -y
libsm6
libxext6
libxrender-dev
libfontconfig1
ffmpeg
imagemagick

RUN sed -i 's###' /etc/ImageMagick-6/policy.xml

Install any needed packages specified in requirements.txt

RUN pip install --trusted-host pypi.python.org -r requirements.txt

Run the web service on container startup. Here we use the gunicorn

webserver, with one worker process and 8 threads.

For environments with multiple CPU cores, increase the number of workers

to be equal to the cores available.

Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app


2023-07-07 19:33:37.755 EET
POST500920 B4.1 spython-requests/2.31.0 https://rap2-igdgw354ha-uc.a.run.app/create_rap
2023-07-07 19:33:41.912 EET
[2023-07-07 16:33:41,899] ERROR in app: Exception on /create_rap [POST]
2023-07-07 19:33:41.912 EET
Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/moviepy/video/VideoClip.py", line 1137, in init subprocess_call(cmd, logger=None) File "/usr/local/lib/python3.9/site-packages/moviepy/tools.py", line 54, in subprocess_call raise IOError(err.decode('utf8')) OSError: convert-im6.q16: attempt to perform an operation not allowed by the security policy @/tmp/tmppo80go9v.txt' @ error/property.c/InterpretImageProperties/3708. 2023-07-07 19:33:41.912 EET convert-im6.q16: no images defined PNG32:/tmp/tmpwrllatrk.png' @ error/convert.c/ConvertImageCommand/3229.
2023-07-07 19:33:41.912 EET
During handling of the above exception, another exception occurred:
2023-07-07 19:33:41.912 EET
Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/app/main.py", line 129, in create_rap create_video(start_at,music_data) File "/app/main.py", line 57, in create_video txt_clip = (TextClip(text, fontsize=24, color="white",font='Helvetica').set_start(start_time).set_duration(clip_duration).set_fps(fps).set_position(( 20,3*background.size[1]//4+15))) File "/usr/local/lib/python3.9/site-packages/moviepy/video/VideoClip.py", line 1146, in init raise IOError(error) OSError: MoviePy Error: creation of None failed because of the following error:
2023-07-07 19:33:41.912 EET
convert-im6.q16: attempt to perform an operation not allowed by the security policy @/tmp/tmppo80go9v.txt' @ error/property.c/InterpretImageProperties/3708. 2023-07-07 19:33:41.912 EET convert-im6.q16: no images defined PNG32:/tmp/tmpwrllatrk.png' @ error/convert.c/ConvertImageCommand/3229.
2023-07-07 19:33:41.912 EET
.
2023-07-07 19:33:41.912 EET
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect

Steps to Reproduce

Any feedback please? I have wasted huge amount of time... The code works perfectly on my local Mac...

Images

No response

@urban-warrior
Copy link
Member

Check your security policy. There is a PATH policy likely preventing you from reading a file on that path. See https://legacy.imagemagick.org/script/security-policy.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants