Search code examples
pythonflaskgoogle-app-engineimagemagickmoviepy

Troubleshooting MoviePy Deployment Issues in Python


My code is currently working on my local machine with moviepy in flask, and I want to deploy it as a web application. I was able to successfully deploy it on Heroku using this buildpack: https://github.com/ello/heroku-buildpack-imagemagick. However, it's consuming too much RAM, and I can't afford the $500 package for 4GB of RAM. I'm now trying to deploy it on the Google App Engine standard environment, but I'm getting this error: This error may be due to the fact that ImageMagick is not installed on your computer. Can you please suggest the best solution for deploying it?

I was able to successfully deploy it on Heroku using this buildpack: https://github.com/ello/heroku-buildpack-imagemagick.


Solution

    1. GAE Standard installs the contents of your requirements.txt file using pip (see documentation). pip is used to download and install packages directly from PyPI (Python Package Index)

    2. The buildpack you referenced downloads and installs imagemagick. If you look at the buildpack, you'll notice that imagemagick is being downloaded from a custom url. This means it isn't on PyPI and so can't be installed by just calling pip install <package>

    3. If you must use GAE Standard, then there might be 2 options you can try

      i) Download/install imagemagick to your Application folder and deploy it together with your App (you'll have to make sure all relative urls for accessing it works)

      ii) Download the tar file of imagemagick to the root of your Application folder and add it to your requirements.txt file using the method described here and then see if GAE standard installs it during deployment

    Alternatively, you can switch to Cloud Run which allows you to do essentially the same thing as the build pack you mentioned i.e. you create a docker file, issue commands to download/install what you want from whatever url, then issue commands to install the contents of your requirements.txt file