macOS Pillow Build

news/2024/7/8 8:09:06 标签: Python, Pillow, Mac, PIL, macOS

Mac_PILLOW.html" title=Pillow>Pillow_1">Mac PILLOW.html" title=Pillow>Pillow

Environment:macOS Mojave
Version:10.14.2
Time:2019.03.01

PIL是python的一个图形库,而最新的一个版本是2009年为1.1.7更新的,虽然这么久远了,但是官方还未说明PIL项目被抛弃。而PILLOW.html" title=Pillow>Pillow是fork PIL项目的,PILLOW.html" title=Pillow>Pillow的作者的原意也是为了促进以及支持PIL的积极开发。

macOS 默认自带python2.7的版本,而我的项目是基于python3进行的,所以我装了一个python3,版本是3.7.2的,这里要做的是导下PILLOW.html" title=Pillow>Pillow项目,然后修改了一些代码,然后替换掉系统的PIL

Note

PILLOW.html" title=Pillow>Pillow支持的python版本

Python2.42.52.62.73.23.33.43.53.63.7
PILLOW.html" title=Pillow>Pillow < 2.0.0YesYesYesYes
PILLOW.html" title=Pillow>Pillow 2.x - 3.xYesYesYesYesYesYes
PILLOW.html" title=Pillow>Pillow 4.xYesYesYesYesYes
PILLOW.html" title=Pillow>Pillow 5.0.x - 5.1.xYesYesYesYes
PILLOW.html" title=Pillow>Pillow >= 5.2.0YesYesYesYesYes

注:PILPILLOW.html" title=Pillow>Pillow在相同的环境下会冲突,所以在安装PILLOW.html" title=Pillow>Pillow之前,请先卸载PIL

预备工作

首先安装python3

其次在GitHub上面导下PILLOW.html" title=Pillow>Pillow项目,在本地进行修改。

git clone https://github.com/python-pillow/PILLOW.html" title=Pillow>Pillow.git MyPILLOW.html" title=Pillow>Pillow

然后卸载掉自己电脑上面的PIL(python3使用pip3)

pip3 uninstall PIL

安装PILLOW.html" title=Pillow>Pillow需要用到Xcode的命令行工具,所以需要先执行

xcode-select --install

执行命令行工具之前可能还要接受许可:

sudo xcodebuild -license

你还需要通过Homebrew安装一些PILLOW.html" title=Pillow>Pillow需要用到的依赖库:

brew install libtiff libjpeg webp little-cms2

正式工作

安装本地PILLOW.html" title=Pillow>Pillow项目。进入MyPILLOW.html" title=Pillow>Pillow目录,并执行安装命令,

pip3 install .

或者通过在未压缩的项目目录下执行安装:

python3 setup.py install

好了,现在你的电脑就已经成功装上PILLOW.html" title=Pillow>Pillow了

问题

我这里会出现一个问题,就是执行安装的时候会出现zlib模块缺少,报错如下:

The headers or library files could not be found for zlib,
a required dependency when compiling PILLOW.html" title=Pillow>Pillow from source.

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html

Traceback (most recent call last):
  File "setup.py", line 803, in <module>
    zip_safe=not (debug_build() or PLATFORM_MINGW), )
  File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 143, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.7/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/usr/local/lib/python3.7/site-packages/setuptools/command/install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 172, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/usr/local/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 158, in call_command
    self.run_command(cmdname)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run
    self.build()
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "setup.py", line 590, in build_extensions
    raise RequiredDependencyException(f)
__main__.RequiredDependencyException: zlib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 815, in <module>
    raise RequiredDependencyException(msg)
__main__.RequiredDependencyException: 

The headers or library files could not be found for zlib,
a required dependency when compiling PILLOW.html" title=Pillow>Pillow from source.

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html

在全世界Google搜索了几遍之后,尝试了N多次方法之后,还是云里雾里的。在不懈的搜索中,尝试了一下某个帖子的方法,结果还真解决了,想哭。帖子地址:https://github.com/pyenv/pyenv/issues/1219

只要执行以下命令,然后重新安装就成功了。

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

笔记,终。


http://www.niftyadmin.cn/n/994284.html

相关文章

教你如何制作RPM安装包

2019独角兽企业重金招聘Python工程师标准>>> checkinstall &#xff0c;是一个能从 tar.gz 类的源代码自动生成 RPM &#xff0f;Debian 或Slackware 安装包的程序 本文环境介绍&#xff1a;本文的示例程序时nagios的插件&#xff0c;目的是把nagios的插件编译安装好…

微软公司昨天发布SQL Server 2005 Samples and Sample Databases更新版——超过100个的SQL Server 2005示例【转】...

从SQL Server 2000到SQL Server 2005&#xff0c;微软公司在SQL Server 2005上投入了相当多的精力。所谓五年磨一剑&#xff0c;与SQL Server 2000相比&#xff0c;SQL Server 2005在各个功能上都有了极为显著的进步&#xff0c;但随之自然而来的在功能上的复杂性也让开发者难以…

MongoDB/MySQL命令行导入导出数据库/表结构/数据/集合

前言 整理了MongoDB和MySQL使用命令行导入导出数据库和表结构的操作。 MongoDB 导出导入数据库集合 使用export导出数据库集合到json文件 mongoexport -h localhost:27017 -u db_name -p password -d [db] -c [collection] -o a.json-h 地址-u 数据库账号名-p 数据库账号密…

android studio - 导入工程报错[Plugin with id 'com.android.application' not found]

出错现象&#xff1a; 大概意思是找不到:com.android.application 插件&#xff0c;以上现象对于初学者来说会经常碰到&#xff0c;下面分析下产生的原因。 原因分析 首先来看看导入后的工程结构&#xff1a; 对于此工程结构&#xff0c;是否有个疑问&#xff1f; 这是未正常同…

MySQL高版本导出数据库,低版本导入不了的问题

前言 有关docker在创建mysql container的时候&#xff0c;初始化数据库失败的问题解决记录&#xff1b; Config docker&#xff1a;19.03.5mysql image&#xff1a;5.7system&#xff1a;centos 7Operate 正常操作 mysql在docker-compose上的配置如下 test_mysql:image: t…

Mac os x 下配置Intellij IDEA + Tomcat 出现权限问题的解决办法

零,写在最前面 帮同学解决问题时在网上找到的,很好用转载一下 一,解决方法 出现的错误提示如下&#xff1a; 下午9:11:27 All files are up-to-date 下午9:11:27 All files are up-to-date 下午9:11:27 Error running Tomcat 8.0.18: Cannot run program “/Users/horse_leo…

Docker打包镜像的两种方式

前言 Docker镜像是一个特殊的文件系统&#xff0c;既提供了运行时所需的程序、库和资源&#xff0c;还提供了相应的配置参数&#xff0c;只是不包含动态数据。我们可以将任何我们的软件产品打包成镜像&#xff0c;以供服务器能够用Docker直接快速安装并部署运行。 System&…

稍有迷茫

耳边音乐响动&#xff0c;却丝毫没有削弱我迷茫的感觉。此刻我宁愿让自己忙起来&#xff0c;疯狂的写CODE&#xff0c;让自己无暇顾及思想上的迷茫。今天因为是在本应该放假的时间里上班&#xff0c; 所以小卖部门都关了&#xff0c;烟没了&#xff0c;坐在公司里总感觉心神不定…