Forums

django-ckeditor upload fails in pythonanywhere with pillow backend(keyerror: “pillow”)

I am using django-ckeditor in my django project.

  • python 3.7
  • Django 2.2.6
  • django-ckeditor 5.8.0
  • Pillow 6.2.1

For ckeditor, I am using image2. Everything works in my local server. But when I deploy my project to pythonanywhere, I get following errors: in google developer tools-> network-> xhr Status Code: 500 Internal Server Error in error.log of pythonanywhere KeyError: 'pillow' and trace to ckeditor_uploader->backends->init.py line 19

If I comment out the following code in my settings.py, ckeditor works in pythonanywhere.

CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_FORCE_JPEG_COMPRESSION = True

Any idea why this is the case? Thanks!

From the django-ckeditor code, it looks like you'll get that error when you do not have Pillow installed. Make sure that you have it installed for the same version of Python that your web app uses or into the virutalenv that your web app is using.

Glenn, thanks for your quick reply. I have Pillow installed in myvenv. now it showing me cannot import name '_imaging' from 'PIL' error trace to myvenv/lib/python3.7/site-packages/PIL/Image.py file line 90from . import _imaging as core.

I searched around, and found this post from stack overflow https://stackoverflow.com/questions/25340698/importerror-cannot-import-name-imaging.

It looks like I should remove other Pillow in python 2.7. I tried to uninstall, but it shows permission denied.

OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/PIL/.libs/libfreetype-6ed94974.so.6.16.1'

Glenn, I also used pip3.7 install -U --user Pillow to install Pillow in local, still same error: "keyerror: 'pillow'"

finally got it work by: 1) not using myvenv from my own project. 2) create virtual environment according to https://help.pythonanywhere.com/pages/Virtualenvs 3) run pip install -r requirements.txt to install all dependencies.

Also it help me , thanku so much