zoukankan      html  css  js  c++  java
  • MAC 下安装PIL

    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 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: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

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

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

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

    sudo pip install pillow

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

  • 相关阅读:
    定时器
    自定义个性化 EditPeople控件
    infopath 2010 调试.
    MOSS 查询
    网站项目建设流程概述
    跨站点显示列表数据 ListViewWebPart
    VIM记事——大小写转换
    事务码记录 程序优化常用st12
    SAP各模块字段与表的对应关系
    固定资产一览
  • 原文地址:https://www.cnblogs.com/sdlypyzq/p/4795426.html
Copyright © 2011-2022 走看看