Search code examples
pythondjangopython-3.xgoogle-app-engine

django-versatileimagefield issues: 'No matching distribution found for python-magic-bin' when deploying to Google App Engine Flex


Since upgrading to django-versatileimagefield==2.0, I just can't get it to play nicely with Google App Engine. Using it as is comes up with the error that others have reported:

ImportError: failed to find libmagic. Check your installation

I've read similar problems that mention adding python-magic-bin==0.4.14 to the requirements. That seems to rectify the problem locally.

When I deploy to Google App Engine, though, it fails when when trying to install python-magic-bin with:

Could not find a version that satisfies the requirement python-magic-bin==0.4.14
No matching distribution found for python-magic-bin==0.4.14

I am using the App Engine Flexible environment with Python 3.7.2. I've tried numerous different ways of installing the required packages and I just can't get it to work.


Solution

  • Try using python-magic - python-magic==0.4.15.

    UPDATED:

    According to this libmagic-dev package is not pre-installed on flex environment, so you will need to switch to custom runtime as described here.

    After that just add libmagic-dev installation to the Dockerfile with:

    RUN apt-get update && apt-get install -y libmagic-dev