1. 安装使用

  1. pip install pil

结果报如下错误

  1. Collecting PIL
  2. Could not find a version that satisfies the requirement PIL (from versions: )
  3. Some externally hosted files were ignored as access to them may be unreliable (use --allow-external PIL to allow).
  4. 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.

  1. pip install PIL --allow-external PIL --allow-unverified PIL

报如下错误 :

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

3.

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

再次执行:

  1. pip install PIL --allow-external PIL --allow-unverified PIL

又报错误 :

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

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

  1. localhost:newlabel zhangxin$ sudo pip install PIL --allow-external PIL --allow-unverified PIL
  2. Password:
  3. 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.
  4. 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.
  5. Collecting PIL
  6. /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.
  7. InsecurePlatformWarning
  8. PIL is potentially insecure and unverifiable.
  9. Installing collected packages: PIL
  10. Successfully installed PIL-1.1.

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

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

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

  1. 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. localstorage 使用

    localstorage作为HTML5的一个特殊属性,在发布时就备受关注:最近总结了其一些小的用法,希望可以抛砖引玉. 因HTML5本地存储只能存字符串,所以所有数据存储的话,都要转化成字符串:而js ...

  2. 以前写过的ajax基础案例(王欢-huanhuan)

    //load方法的使用   $('#loadBtn').click(function(){    //responseTxt 包含来自请求的结果数据 //statusTxt 包含请求的状态(" ...

  3. [CC150] Find a line passing the most number of points

    Problem: Given a two-dimensional graph with points on it, find a line which passes the most number o ...

  4. 【原创】Matlab中plot函数全功能解析

    [原创]Matlab中plot函数全功能解析 该帖由Matlab技术论(http://www.matlabsky.com)坛原创,更多精彩内容参见http://www.matlabsky.com 功能 ...

  5. nojs iis asp.net mvc

    http://blogs.msdn.com/b/scott_hanselman/archive/2011/11/29/window-iis-node-js.aspx http://www.hansel ...

  6. 【POJ 1988】 Cube Stacking (带权并查集)

    Cube Stacking Description Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)id ...

  7. Centos6.5 安装Vim7.4

    系统本身会带Vim7.2都版本,其实也够用,强迫症患者可以按以下操作升级成Vim7.4: (1)切换到root权限 (2)卸载 rpm -qa | grep vim yum remove vim vi ...

  8. hadoop2.2编程:mapreduce编程之二次排序

    mr自带的例子中的源码SecondarySort,我重新写了一下,基本没变. 这个例子中定义的map和reduce如下,关键是它对输入输出类型的定义:(java泛型编程) public static ...

  9. C# WinForm捕获未处理的异常

    using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; namespa ...

  10. 【Dog】