'Unable to install Pillow in venv on ubuntu

I need help fixing this. I have pillow 7.0.0 installed but it is not accessible in my virtual environment. Trying to install using pip install pillow in the virtual env throws the error below. Can someone shed some light on how to fix this?

Collecting pillow
  Using cached Pillow-9.1.0.tar.gz (49.8 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pillow
  Building wheel for pillow (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [156 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
     ...

      x86_64-linux-gnu-gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -DPILLOW_VERSION=\"9.1.0\" -I/tmp/pip-install-dxz6gg5z/pillow_5c0ecf282df741a599c5f2ec14a30181 -I/usr/local/include -I/usr/include -I/home/onah/PycharmProjects/ecommerce/venv/include -I/usr/include/python3.11 -c src/_imaging.c -o build/temp.linux-x86_64-cpython-311/src/_imaging.o
      x86_64-linux-gnu-gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/tmp/pip-install-dxz6gg5z/pillow_5c0ecf282df741a599c5f2ec14a30181 -I/usr/local/include -I/usr/include -I/home/onah/PycharmProjects/ecommerce/venv/include -I/usr/include/python3.11 -c src/_imagingmorph.c -o build/temp.linux-x86_64-cpython-311/src/_imagingmorph.o
      



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source