学习Python:Windows 64位系统使用PIL
2014-12-03 19:02
357 查看
Win7 64 位 安装第三方库PIL(Python Imaging Library),下载地址:http://www.pythonware.com/products/pil/,安装PIL-1.1.7.win32-py2.7.exe,出现
Python version 2.7 required, which was not found in the registry,如下图所示:
解决方法:建立一个文件 register.py 内容如下, 然后cmd,DOS命令行下输入:python register.py执行该脚本,会显示“python 2.7 is already registered”。
说明,安装PIL-1.1.7.win32-py2.7.exe出现问题,原因在于:我安装的python是64位的,pil官方只有32位的。安装时会提示找不到python的安装信息,怎么办呢?只好考虑使用其他的第三方库代替,好在有非官方的64位库(官方源码编译版)。
解决方法:使用另一个第三方PIL库,Pillow-2.6.1.win-amd64-py2.7,根据python的版本和系统的版本到网站:http://www.lfd.uci.edu/~gohlke/pythonlibs/上下载相应的版本:
由Pillow的说明可知,使用的时候,应该使用 from PIL import Image代替import Image,简单测试一下:
程序正常运行。
Python version 2.7 required, which was not found in the registry,如下图所示:
解决方法:建立一个文件 register.py 内容如下, 然后cmd,DOS命令行下输入:python register.py执行该脚本,会显示“python 2.7 is already registered”。
# # script to register Python 2.0 or later for use with win32all # and other extensions that require Python registry settings # # written by Joakim Loew for Secret Labs AB / PythonWare # # source: # http://www.pythonware.com/products/works/articles/regpy20.htm # # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html import sys from _winreg import * # tweak as necessary version = sys.version[:3] installpath = sys.prefix regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version) installkey = "InstallPath" pythonkey = "PythonPath" pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % ( installpath, installpath, installpath ) def RegisterPy(): try: reg = OpenKey(HKEY_CURRENT_USER, regpath) except EnvironmentError as e: try: reg = CreateKey(HKEY_CURRENT_USER, regpath) SetValue(reg, installkey, REG_SZ, installpath) SetValue(reg, pythonkey, REG_SZ, pythonpath) CloseKey(reg) except: print "*** Unable to register!" return print "--- Python", version, "is now registered!" return if (QueryValue(reg, installkey) == installpath and QueryValue(reg, pythonkey) == pythonpath): CloseKey(reg) print "=== Python", version, "is already registered!" return CloseKey(reg) print "*** Unable to register!" print "*** You probably have another Python installation!" if __name__ == "__main__": RegisterPy()安装成功后,进行简单的编程测试,测试代码如下:
import Image im = Image.open('Lena.jpg') w, h = im.size im.thumbnail((100, 100)) im.save('Lena_2.jpg', 'jpeg')运行程序,提示:
JPEG support not available
说明,安装PIL-1.1.7.win32-py2.7.exe出现问题,原因在于:我安装的python是64位的,pil官方只有32位的。安装时会提示找不到python的安装信息,怎么办呢?只好考虑使用其他的第三方库代替,好在有非官方的64位库(官方源码编译版)。解决方法:使用另一个第三方PIL库,Pillow-2.6.1.win-amd64-py2.7,根据python的版本和系统的版本到网站:http://www.lfd.uci.edu/~gohlke/pythonlibs/上下载相应的版本:
由Pillow的说明可知,使用的时候,应该使用 from PIL import Image代替import Image,简单测试一下:
from PIL import Image, ImageFilter im = Image.open('Lena.jpg') # 模糊图片 im.filter(ImageFilter.GaussianBlur) im.save('Lena_2.jpg', 'jpeg')
程序正常运行。
相关文章推荐
- MySQL学习第四天 Windows 64位系统下使用MySQL
- Win10下python3和python2同时安装并解决pip共存问题 特别说明,本文是在Windows64位系统下进行的,32位系统请下载相应版本的安装包,安装方法类似。 使用python开
- MySQL学习第四天 Windows 64位系统下使用MySQL
- 32位系统下使用Windows 7 USB DVD Download Tool创建64位win7系统安装U盘
- mod_wsgi windows 64位系统安装(python扩展包)
- linux学习使用总结-linux系统的安装和与windows双系统共享,linux常用的基本命令,今天贴在这里和大家分享
- windows 64位安装Python以及PIL模块详细步骤
- Python: Window 64位 Python 使用PIL && 验证码生成
- 32位系统下使用Windows 7 USB DVD Download Tool创建64位win7系统安装U盘
- Windows 7 x64系统安装CRFsuite给Python使用
- 【Python学习笔记】windows上virtualenv 安装及使用
- python判断windows系统是32位还是64位的方法
- python使用wmi模块获取windows下的系统信息 监控系统
- python检测windows系统是32还是64位
- python windows下通过SSH获取linux系统cpu、内存、网络使用情况
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法
- 32位系统下使用Windows 7 USB DVD Download Tool创建64位win7系统安装U盘
- Linux 64位系统安装Python PIL模块
- 【汇编学习(三)】Windows 7 64位下 Debug 的安装及使用
- Windows 64位系统下安装mysql,配置使用以及修改密码!