Da Chen Da Chen - 2 months ago 23
Python Question

Pillow has already installed, but appears ImportError - Python3.5 Ubuntu

I used

sudo pip3
to install
Pillow
in the Python 3.5 (without
sudo
it will prompt
PermissonError
) and it said


Requirement already satisfied (use --upgrade to upgrade): Pillow in /usr/local/lib/python3.5/dist-packages


But when I tried to use it in the Program. It shows:


File "./level7.py", line 4, in <module>

  from Pillow import Image

ImportError: No module named 'Pillow'


My first few lines in program are:


1 #! /usr/bin/env python3

2 # -*- coding: utf-8 -*-

3


4 from Pillow import Image


Besides, I found that in
/home/-uname/.local/lib
file, there is a
Python2.7
file, but no Python3.5.

What's the relation between
/usr/local
and
/home/-uname/.local
? And how to fix this problem?

Answer

Based off of the documentation for Pillow, you are actually supposed to import it as:

from PIL import Image