码迷,mamicode.com
首页 > 系统相关 > 详细

MAC 下安装PIL

时间:2015-09-09 18:51:04      阅读:501      评论:0      收藏:0      [点我收藏+]

标签:

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.10.sdk/usr/include/tk.h:78:11: fatal error: X11/Xlib.h file not found
  #       include <X11/Xlib.h>
                  ^
  1 error generated.
  error: command cc failed with exit status 1
  
  ----------------------------------------
  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.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /
usr/local/include/X11

再次执行:

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

又报错误 :

    100% |████████████████████████████████| 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/31/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 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 317, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, wb) as fdst:
IOError: [Errno 13] 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 sudos -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 sudos -H flag.
Collecting PIL
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: 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.7

 

MAC 下安装PIL

标签:

原文地址:http://www.cnblogs.com/sdlypyzq/p/4795426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!