Skip to content Skip to sidebar Skip to footer

Django Error: Cannot Use Imagefield Because Pillow Is Not Installed

I'm currently learning how to use Django to develop a web service. As I go through an online course on Udemy, I ran into a problem using ImageField in models.py. My problem is that

Solution 1:

I ran into this issue in a docker container. Pillow won't install without jpeg and zlib header and library support, so I added zlib-dev and jpeg-dev to the build, and then removed them after installing Pillow. Of course then Pillow refused to import, because libjpeg and friends are missing. The solution was to add back the relevant (non-dev) packages, and everything started working as desired.

Solution 2:

In order to define a virtualenv for your project in pycharm, first go to this path :

file -> settings -> Project -> Project Interpreter

now you can see all project that are opened in pycharm. select your desired project, and click Project Interpreter config button, then select Add local python interpreter. in this form, select Existing environment. now in button inside Interpreter you can select your desired virtualenv (myvirtualenv -> bin -> python3.x)

Solution 3:

I don't know the specific reasons but it seems like I found a solution for the situation where the virtualenv created by PyCharm is not recognized by the terminal in PyCharm. The solution is to create a virtualenv by using virtualenv library in plain python and set it as the project interpreter in PyCharm, rather than creating a virtualenv through PyCharm.

Post a Comment for "Django Error: Cannot Use Imagefield Because Pillow Is Not Installed"