Python3 PIL Pillow Ubuntu安装

fis*_*ish 2 installation ubuntu python-imaging-library pillow python-3.4

我正在运行Ubuntu 14.04 LTS.我安装了Python 2.7和Python 3.4.在Linux中安装Python软件包时,我相对比较新手.

我只是想在Python 3.4中安装并访问PIL的图像库.我的理解是,这是通过安装PIL的现代分支Pillow来实现的.

在我的挣扎中似乎成功地让PIL在Python 2.7中工作,但我仍然无法在3.4中使用它.

我得到了pippip3.当我进入

sudo pip3 install Pillow
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息,暗示它已安装:

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

然而,当我尝试在Python 3.4中导入PIL或Pillow时,找不到该模块.

我觉得我只是缺少一些简单的东西.

jta*_*lor 6

枕头按照python3-pilUbuntu 14.04(Trusty Tahr)打包.您可以在系统范围内安装它:

sudo apt-get install python3-pil
Run Code Online (Sandbox Code Playgroud)

您似乎早先已经使用pip安装了Pillow ,但系统Python不会读取它将其放入的默认路径.您可以使用以下命令将其添加到搜索路径:

export PYTHONPATH=/usr/local/lib/python3.4/dist-packages:/usr/local/lib/python3.4/site-packages
Run Code Online (Sandbox Code Playgroud)

通常,您最好使用它pip --user来避免破坏系统安装或尽可能坚持使用基本Python模块的打包变体.

  • @fish你可以解释一下你做了什么让它起作用了吗? (3认同)