ImageField in models.py - installation of pillow in VSC

Dear all,

Since several days I am trying to fix a simple installation issue. I need help.

I added an ImageField in my models.py file. To use the ImageField I need Pillow.

models.py:

from django.db import models
from django.contrib.auth.models import User

class Product(models.Model):
    user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)  
    name = models.CharField(max_length=200, null=True, blank=True)  
    image = models.ImageField(null=True, blank=True)  
    brand = models.CharField(max_length=200, null=True, blank=True)
    category = models.CharField(max_length=200, null=True, blank=True)
    description = models.TextField(null=True, blank=True)
    rating = models.DecimalField(max_digits=7, decimal_places=2, null=True, blank=True) 
    numReviews = models.IntegerField(null=True, blank=True, default=0)
    price = models.DecimalField(max_digits=7, decimal_places=2, null=True, blank=True)
    countInStock = models.IntegerField(null=True, blank=True, default=0)
    createdAt = models.DateTimeField(auto_now_add=True)
    _id = models.AutoField(primary_key=True, editable=False)  

    def __str__(self): 
        return self.name

in terminal:

iMac-de-admin:backend admin$ pip install pillow
WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/lib/python3.9/site-packages
sysconfig: /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/lib/python3.9/site-packages
sysconfig: /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/include/python3.9/UNKNOWN
sysconfig: /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/UNKNOWN
WARNING: Value for scheme.scripts does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local/bin
sysconfig: /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin
WARNING: Value for scheme.data does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: /usr/local
sysconfig: /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Requirement already satisfied: pillow in /usr/local/lib/python3.9/site-packages (8.3.1)

What does this Warning means:

WARNING: Additional context:
user = False
home = None
root = None
prefix = None

So pillow is installed. PIL is not installed in this project.

When I run the server I get this error:

python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 469, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
base.Product.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip install Pillow".

System check identified 1 issue (0 silenced).

If I use : “python -m pip install Pillow”

iMac-de-admin:backend admin$ python -m pip install Pillow
/usr/bin/python: No module named pip

Do you have any idea what I have to change or to do that I can use the ImageField?

Thank you

From your prompt, am I correct in assuming this is being done on a Mac?

Sorry. Yes, it is an iMac of 2011.

I found a solution for me:

pip install pillow==8.0.1

I do not know if there is an other version possible to use but with that version (8.0.1) I am able to run the server.

The information was found in this issue ticket: