skip to Main Content

I deployed my django site online on apache in mod_wsgi everything works so far
I then installed:

pip install --pre xhtml2pdf

to generate pdf documents
with the code that goes with it, after restarting the server and when I refresh my site I have an Internal Server Error error,
And then after consulting the error.log file
I have this:

ImportError: cannot import name '_imaging' from 'PIL' (/home/ubuntu/myproject/env/lib/python3.10/site-packages/PIL/__init__.py)

And when I run from the command line, I get no error.

Python 3.10.7 (main, Nov 24 2022, 19:45:47) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> from PIL import _imaging as core
>>>

this has to do with wsgi or??
where is the problem ???

2

Answers


  1. I faced the same problem a while ago, if you are using Linux/Ubunut then you can try installing the libjpeg library and its development files, which are required for PIL to work correctly.

    sudo apt-get install libjpeg-dev

    After you’ve installed the dependencies, try reinstalling the PIL package:

    pip install Pillow

    Once PIL is installed correctly, restart your server and it should work.

    Login or Signup to reply.
  2. You can upgrade this package using below command:

    pip install -U Pillow
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search