Python3 PIL Pillow Ubuntu Install

2019-02-26 04:31发布

I'm running Ubuntu 14.04 LTS. I have both Python 2.7 and Python 3.4 installed. I'm relatively novice when it comes to installing Python Packages in Linux.

I'm just trying to install and get access to PIL's image library in Python 3.4. It is my understanding that this is achieved by installing Pillow, the modern fork of PIL.

It seems in my floundering I managed to successfully get PIL working in Python 2.7, but I still cannot get it working in 3.4.

I got pip and pip3. When I enter

sudo pip3 install Pillow

I get the following error message, implying it is is installed:

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

Yet when I try to import either PIL or Pillow in Python 3.4, the module is not found.

I feel like I'm just missing something simple.

1条回答
淡お忘
2楼-- · 2019-02-26 05:15

Pillow is packaged as python3-pil in Ubuntu 14.04 (Trusty Tahr). You can install it system-wide with:

sudo apt-get install python3-pil

You seem to have already installed Pillow with pip earlier, but the default path it pip places it in is not read by the system Python. You can add it to the search path with:

export PYTHONPATH=/usr/local/lib/python3.4/dist-packages:/usr/local/lib/python3.4/site-packages

Generally you are better off using pip --user to avoid breaking the system installations or to stick with the packaged variants of base Python modules if possible.

查看更多
登录 后发表回答