1. 安装使用

pip install pil

结果报如下错误

Collecting PIL
Could not find a version that satisfies the requirement PIL (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external PIL to allow).
No matching distribution found for PIL

2.

This is due to changes in the new version of Pip. Run pip --version and I'm willing to bet you are running 1.5. See the changelog here. This new default behavior enhances security. In PIL's case, the file you are installing actually comes from effbot.org (thus --allow-external) and PyPi doesn't have a checksum to guarantee validity (thus --allow-unverified).

Also, you might consider using the Pillow replacement to PIL.

pip install PIL --allow-external PIL --allow-unverified PIL

报如下错误 :

 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10..sdk/usr/include/tk.h::: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
^
error generated.
error: command 'cc' failed with exit status ----------------------------------------
Failed building wheel for PIL
Failed to build PIL

3.

sudo ln -s  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.pl
atform/Developer/SDKs/MacOSX10..sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /
usr/local/include/X11

再次执行:

pip install PIL --allow-external PIL --allow-unverified PIL

又报错误 :

    % |████████████████████████████████| 507kB 97kB/s
Building wheels for collected packages: PIL
Running setup.py bdist_wheel for PIL
Stored in directory: /Users/zhangxin/Library/Caches/pip/wheels/ba//4a/9a5596f0640c9099a4302a71b56b7581e16e0d0b5a8f30ce3e
Successfully built PIL
Installing collected packages: PIL
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line , in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line , in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line , in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line , in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line , in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line , in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line , in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line , in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno ] Permission denied: '/Library/Python/2.7/site-packages/PIL.pth'

这次是忘了加sudo,加上就OK了。

localhost:newlabel zhangxin$ sudo pip install PIL --allow-external PIL --allow-unverified PIL
Password:
The directory '/Users/zhangxin/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/zhangxin/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting PIL
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
PIL is potentially insecure and unverifiable.
Installing collected packages: PIL
Successfully installed PIL-1.1.

4. 在使用ImageFont.truetype(fontname, 36)时又出现错误:

Traceback (most recent call last):
File "generate.py", line , in <module>
font = ImageFont.truetype(fontname, )
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line , in truetype
return FreeTypeFont(filename, size, index, encoding)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line , in __init__
self.font = core.getfont(file, size, index, encoding)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line , in __getattr__
raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

5. 后来,我改变主意了,我卸载了pil,我安装pillow。

sudo pip install pillow

然后成功了。叫我神经病吧

MAC 下安装PIL的更多相关文章

  1. Mac下安装 PIL

     最近入手MacBook Pro 在配置PIL环境的时候遇到一些问题.现在把解决方式记录下来,希望对有需要的有所帮助. 1. 安装brew : brew 又叫Homebrew,是Mac OSX上的软件 ...

  2. Mac 下安装Jenkins

    Mac 下安装Jenkins 开始 Jenkins是一个基于Java开发的一种持续集成工具,用于建工持续重复的工作,功能包括: 持续的软件版本发布/测试项目 监控外部调用执行的工作. 近期打算搭建自动 ...

  3. MAC下安装与配置MySQL

    MAC下安装与配置MySQL   MAC下安装与配置MySQL 一 下载MySQL 访问MySQL的官网http://www.mysql.com/downloads/ 然后在页面中会看到“MySQL ...

  4. Mac下安装UPnP Inspector

    由于工作中需要用到UPnP Inspector这个工具,而这个工具在windows下安装非常简单,在Mac下安装却很麻烦,在此记录安装流程. 这个工具依赖于两个其他的库:Coherence(一个DLN ...

  5. Mac下安装Wireshark,双击闪退

     Mac OS X上使用Wireshark抓包(http://blog.csdn.net/phunxm/article/details/38590561) Mac下安装Wireshark /Appli ...

  6. Mac下安装zshell

    Mac 下安装zshell 什么是shell 大多数命令行用户接触最多的是Bash,因为Bash是各个版本操作系统(Linux&Mac)的默认shell. 查看当前使用的shell $ ech ...

  7. 【高可用HA】Apache (1) —— Mac下安装Apache Httpd到自定义路径(非/etc/apache2)

    Mac下安装Apache Httpd httpd版本: httpd-2.4.17 参考来源: Tomcat Clustering - A Step By Step Guide Apache HTTP ...

  8. 《OD大数据实战》mac下安装nginx+php

    一.mac安装nginx + php + php-fpm  或apache + php 1. Mac 下 Nginx.MySQL.PHP-FPM 的安装配置 2. Mac下安装LNMP(Nginx+P ...

  9. Mac下安装HBase及详解

    Mac下安装HBase及详解 1. 千篇一律的HBase简介 HBase是Hadoop的数据库, 而Hive数据库的管理工具, HBase具有分布式, 可扩展及面向列存储的特点(基于谷歌BigTabl ...

随机推荐

  1. Linux网络应用编程之Packet Tracer安装及界面介绍

    Packet Tracer入门 一,Packet Tracer介绍 packet tracer 是由Cisco公司发布的一个辅助学习工具,为学习思科网络课程的初学者去设计.配置.排除网络故障提供了网络 ...

  2. 利用Linux系统生成随机密码的10种方法

    Linux操作系统的一大优点是对于同样一件事情,你可以使用高达数百种方法来实现它.例如,你可以通过数十种方法来生成随机密码.本文将介绍生成随机密码的十种方法. 1. 使用SHA算法来加密日期,并输出结 ...

  3. 浏览器测试功能(jquery1.9以后已取消)

    // 1.9以后取消了msie这些私有方法判断.这里封装加回. var matched = (function(ua) { ua = ua.toLowerCase(); var match = /(o ...

  4. .NET异步操作学习之一:Async/Await中异常的处理

    以前的异常处理,习惯了过程式的把出现的异常全部捕捉一遍,然后再进行处理.Async/Await关键字出来之后的确简化了异步编程,但也带来了一些问题.接下来自己将对这对关键字进行学习.然后把研究结果放在 ...

  5. J2EE中的HttpSession

    J2EE中的HttpSession总结: ①什么是session? session是服务器端技术,利用这个技术,服务器在运行时可以为每一个浏览器创建一个共享的session对象,由于 session为 ...

  6. Android中的pix,sp,dp相关概念

    px( pixel) 像素,可以简单的理解为一个点或方块,用以颜色的显示(单位),一般指印刷品或屏幕设置设备的颜色显示定义. dip(device independent pixels)设备独立像素. ...

  7. iOS面试题16719-b

    1. 反转二叉树,不用递归 /*** Definition for a binary tree node.* public class TreeNode {*     int val;*     Tr ...

  8. NOI冲刺计划2

    吐槽:距离上一次写计划还没有一个月呢,咋又喊要重写捏?可以直接从上一次的计划粘上个一大半. bzoj刷题速度还是在计划之内的,这大半个月中,我bzoj刷进500道,知识方面主要是把莫比乌斯反演系统性的 ...

  9. Codeforces Round #198 (Div. 2) —— B

    B题是一个计算几何的题,虽然以前看过计算几何的ppt,但一直都没有写过: 昨晚比赛的时候本来想写的,但是怕不熟练浪费时间,太可惜了! 其实没必要选出一个最大的矩形: 以矩形的一条对角线为轴,向上或者向 ...

  10. jquery mobile backbone

    http://www.appliness.com/getting-started-with-html-mobile-application-development-using-jquery-mobil ...