ImageField needs Pillow to be installed - django

I made a model with ImageField(). But whenever I run python manage.py it says you need to install pillow.ERRORS:
sho.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".

It did tell you how to fix it , You dont have the pillow library installed so the imagefield wont work unless you run python -m pip install Pillow . Running the command will solve the problem

I think you are using old version of Django old version don't support for ImageField() without installing pillow. just update the Django package by running following command
you must do the following:
1- Update pip
python -m pip install --upgrade pip
2- If you already install Django update by using the following command
pip install --upgrade Django
or you can uninstall it using the following command
pip uninstall Django
3- If you don't install it yet use the following command
python -m pip install Django
4- Type your code
Enjoy

Install Pillow library, pip install Pillow
in your models.py import Pillow as below
from PIL import Image

Related

Pillow installed correctly but Image Field got error Pillow is not installed - Django

I install correctly Pillow using all these comments: Pip install Pillow - Pip Insall Pillow==6.2.0 -
pip install Pillow
Requirement already satisfied: Pillow in c:\program files (x86)\python38-32\lib\site-packages (7.2.0)
python -m pip install --upgrade Pillow
python -m pip install --upgrade Pillow
Requirement already up-to-date: Pillow in c:\program files (x86)\python38-32\lib\site-packages (7.2.0)
And update Pip as successfully, but when I want to add ImageField
like this: image = models.ImageField(), I've got this error:
eCommerce.Item.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
HINT: Get Pillow at https://pypi.org/project/Pillow/ or run the command "pip install Pillow".
some people say this is for the version of your windows but I install pip
for win64
please help, thank you
Let's say you call manage.py using:
python manage.py runserver
python3.7 manage.py runserver
or something similar try installing pillow using
python -m pip install pillow==6.2.0
this will install it into the targeted version, make sure to replace python with whichever command you used to run manage.py, like python3.8 or similar.
Hope this would help!

pip command by default using python 3...how to change it to python 2?

I am using macOS Sierra 10.12 and after I upgraded my OS I can no longer install packages for python 3 using pip. Before I used to use pip for python2 and pip3 for python 3 as I have both versions of Python. But now I can no longer use pip to install libraries for python2.
Can anyone help me how can I change my default pip installer to python2? So that I can just use pip install in order to install for python 2.
For your information - when I only type python on terminal it says my default is python 2.7.
on running
which pip
I got /usr/local/bin/pip
Which meant it was pointing to pip2
To change default pip to pip3, run
sudo ln -s /usr/local/bin/pip3 /usr/local/bin/pip
install pip for Python2.7 with easy_install:
sudo easy_install-2.7 pip
now you can use pip for the same specific version of Python:
sudo pip2.7 install BeautifulSoup

Pip installation bug

So I tried to install pip using the get-pip.py file, and when I ran the file, terminal told me I already had pip installed on 2.7. However, when I try to find the version of my pip, terminal tells me pip doesn't exist and points to a version of 3.5 I have installed. Clearly my issue is that I have pip installed on v2.7 but the pip command is linked to v3.5. Any clues on how to fix?
Here's a picture of my terminal output:
To install a package in a particular version of python, use the following commands always:
For python 2.x:
sudo python -m pip install [package]
For python 3.x:
sudo python3 -m pip install [package]
This should resolve the doubt of which python version is the given package getting installed for.
Note: This is assuming you have not created aliases for the python command

Django 1.9 Compiling Error

I created a virtualenv and downloaded Django with the below commands:
virtualenv tester
source tester/bin/activate
pip install django
and below is the response:
Downloading/unpacking django
Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Compiling /home/romaan/workspacepy/tester/build/django/django/conf/app_template/apps.py ...
File "/home/romaan/workspacepy/tester/build/django/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
Compiling /home/romaan/workspacepy/tester/build/django/django/conf/app_template/models.py ...
File "/home/romaan/workspacepy/tester/build/django/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
Successfully installed django
Please help me to get rid of this error. All though it says Successfully installed django, I am keen on understanding and getting rid of this syntax error.
Or Should I just wait for the bug fix to happen?
This looks like the setuptools issue mentioned in the Django 1.9 release notes: https://docs.djangoproject.com/en/1.9/releases/1.9/#syntaxerror-when-installing-django-setuptools-5-5-x
Try to run pip install --upgrade pip before running pip install django
Those can't, and shouldn't, be fixed. Those are template files which are substituted at project creation time, and are not valid Python syntax. They shouldn't be compiled at install time but rather at project creation time.
These steps worked for me:
$ sudo python -m pip install --upgrade --force setuptools
$ sudo python -m pip install --upgrade --force pip
$ sudo pip install django==1.9
pip install -U pip ran fine but didn't fix my issue
I got the same message when I was trying pip install django.
I thought to try a previous version so I tried pip install
django-1.9.
It said "Real name of requirement Django-1.9 is django-503".
So pip install Django-503 worked fine for me.

Installing specific version of django

I am trying to install django 1.4.3 using pip. I am running
$ sudo pip unistall django
$ sudo pip install django==1.4.3
and I get the following messagin during installation
Requested django==1.4.3, but installing version 1.5.1
I can give more code if needed. Thanks!
I met the same problem while install Twisted.
requiring 10.0.0 but install 13.0.0,
finally I get the 10.0.0 package and download src, mannually installed it.
just change https://pypi.python.org/pypi/Twisted/13.0.0 to https://pypi.python.org/pypi/Twisted/10.0.0
A simple solution is to create a requirements.txt file:
pip freeze > requirements.txt
Then, change the django version inside your requirements.txt
file manually:
Django==1.4.3
and finally run the command:
pip install -r requirements.txt
You should have your required Django version.
Cheers!