当前位置: 首页 > 知识库问答 >
问题:

如何在Mac OS上安装PIL与pip?

壤驷升
2023-03-14

我试图安装PIL(Python图像库)使用命令:

sudo pip install pil

但我得到了以下信息:

Downloading/unpacking PIL
  You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
  Downloading PIL-1.1.7.tar.gz (506kB): 506kB downloaded
  Running setup.py egg_info for package PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    
Installing collected packages: PIL
  Running setup.py install for PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    --- using frameworks at /System/Library/Frameworks
    building '_imaging' extension
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o
    unable to execute clang: No such file or directory
    error: command 'clang' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-AYrxVD-record/install-record.txt --single-version-externally-managed:
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py

running install

running build

.
.
.
.

copying PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.8-intel-2.7

running build_ext

--- using frameworks at /System/Library/Frameworks

building '_imaging' extension

creating build/temp.macosx-10.8-intel-2.7

creating build/temp.macosx-10.8-intel-2.7/libImaging

clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o

unable to execute clang: No such file or directory

error: command 'clang' failed with exit status 1

----------------------------------------
Cleaning up…

您能帮我安装PIL

共有3个答案

殳毅
2023-03-14

使用apt安装非常简单,使用此命令即可完成安装

sudo apt-get install python-PIL

sudo pip install pillow

或者

sudo easy_install pillow
顾乐家
2023-03-14

这对我很有用:

apt-get install python-dev
apt-get install libjpeg-dev
apt-get install libjpeg8-dev
apt-get install libpng3
apt-get install libfreetype6-dev
ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib

pip install PIL  --allow-unverified PIL --allow-all-external
冀翰翮
2023-03-14
  1. 如前所述,安装Xcode和Xcode命令行工具
  2. 用枕头代替,因为PIL基本上已经死了。枕头是PIL的一个保持叉

https://pypi.org/project/Pillow/

pip install Pillow

如果您同时安装了两个python,并且希望为Python3安装此选项:

python3 -m pip install Pillow
 类似资料:
  • 问题内容: Command “/usr/bin/python -u -c “import setuptools, tokenize;file=’/private/tmp/pip-build-J1I0ox/pymssql/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘\r\n’, ‘\n’);f.cl

  • 本小节我们将介绍如何在 MacOS 平台安装 Java 。 如果你想在其他平台安装 Java,请查看对应平台的安装教程: 在 Windows 上安装 Java 在 Linux 上安装 Java 1. 下载安装包 我们首先打开 Oracle 官网的 JDK 下载地址,找到 Java SE 14 版块,点击 JDK Download 按钮。 点击 JDK Download 按钮后我们会跳转到 JDK

  • 问题内容: 我已经尝试使用Google搜索和查找其他人的问题。但是,我仍然找不到在Mac OS X 10.7.2 Lion上安装PIL(适用于python 2.6或2.7)的清晰/简单配方。 问题答案: 如果您使用自制软件,则可以使用来安装PIL 。然后,您可能需要将安装目录()添加到PYTHONPATH中,或者将PIL目录本身的位置添加到任何site- packages目录中名为file的文件中

  • 问题内容: 昨天我大部分时间都在寻找安装的明确答案(Python的软件包管理器)。我找不到一个好的解决方案。 如何安装? 问题答案: 我很惊讶没有人提到这一点-自2013年以来,python本身就能够安装,不需要外部命令(也不需要Internet连接)。 这将创建与安装类似的安装。

  • 问题内容: 我正在尝试使用Homebrew在Mac OS 10.6上设置MySQL 。 一切顺利,我也成功了。 但是,当我尝试使用以下方法连接到服务器时: 我得到: 我也尝试过访问, 但是使用或不使用密码都无法使用。 这是全新计算机上的全新安装,据我所知,必须使用root用户密码才能访问新安装。我也尝试过: 但我也得到 问题答案: 我认为使用已安装的旧版本mysql可以最终胜任这一职位。我遇到了同

  • 本文向大家介绍ansible 在MacOS上安装Ansible,包括了ansible 在MacOS上安装Ansible的使用技巧和注意事项,需要的朋友参考一下 示例 有两种主要方法可以使用Homebrew或Pip软件包管理器在OS X上安装Ansible。 如果您有自制软件,则可以使用以下命令安装最新的Ansible: 要安装Ansible 1.9.X分支,请使用以下命令: 要安装Ansible