配置:Win7 64位
不过折腾到最后,没有使用PIL,官方的PIL很久木有更新了,换了Pillow,是PIL的衍生吧,一直有更新,但是两者不可在同一环境共存。
1 Python version 2.7 required,which was not found in the registry.
官方下载http://www.pythonware.com/products/pil/,安装PIL,出现如下错误提示,Python version 2.7 required,which was not found in the registry.

解决方案:

 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()
将如上文件执行,进行注册,之后再尝试安装,成功。
 
2 DLL load failed:%1不是有效的Win32应用程序
但是之后在使用_imaging模块时又报错:
DLL load failed:%1不是有效的Win32应用程序
是因为安装的Python是64位,PIL却是32位,而官方发布的只有32位,找个非官方的64位安装。
 
3 如何卸载目前安装的PIL
在PIL安装路径下看到RemovePIL.exe文件,执行失败,提示:This program is normally started by Windoows。
在该路径中可看到PIL-wininst.log,里面有记录卸载的命令,根据提示执行卸载命令即可。

 

原因:

python有64位的,pil官方只有32位的。安装时会提示找不到python的安装路径。

64位Win7下无法安装PIL库的原因

PIL官方http://www.pythonware.com/products/pil/提供的PIL二进制安装库都是32位的。

64位程序和32位程序检测注册表的位置是不一样的:

64-bit: HKEY_LOCAL_MACHINESOFTWAREPython

32-bit: HKEY_LOCAL_MACHINESOFTWAREWow6432NodePython

我安装的是Python2.7 x64版,所以相关信息是在 HKEY_LOCAL_MACHINESOFTWAREPython下面,32位程序在HKEY_LOCAL_MACHINESOFTWAREWow6432NodePython 下面找Python安装信息,肯定是找不到了。

解决:

幸好有人提供了非官方的64位库(官方源码编译版)。

http://www.lfd.uci.edu/~gohlke/pythonlibs/

安装PIL遇到的问题的更多相关文章

  1. Mac osx 安装PIL出现Some externally hosted files were ignored (use --allow-external PIL to allow).

    出现这个问题Some externally hosted files were ignored (use --allow-external PIL to allow)的主要原因是PIL的一些依赖库还没 ...

  2. Mac下安装 PIL

     最近入手MacBook Pro 在配置PIL环境的时候遇到一些问题.现在把解决方式记录下来,希望对有需要的有所帮助. 1. 安装brew : brew 又叫Homebrew,是Mac OSX上的软件 ...

  3. 安装PIL库时提示python未注册错误(自定义python安装路径)

    import sys from _winreg import * # tweak as necessary version = sys.version[:3] installpath = sys.pr ...

  4. 64位Python安装PIL

    写个小程序需要安装PIL,但是官网只有32位,无法找到64位安装路径.根据网上教程自行编译,但是由于VS版本问题总是提示“Python error: Unable to find vcvarsall. ...

  5. Mac系统下安装PIL

    安装PIL依赖JPEG.Freetype.LittleCMS, 首先安装这三个环境(第一至三步): 第一步:安装JPEG http://www.ijg.org/files/jpegsrc.v8c.ta ...

  6. ubuntu Python2.7 安装PIL问题

    $sudo easy_install PIL WARNING: '' not a valid package name; please use only.-separated package name ...

  7. 关于python下安装PIL库遇到的问题及解决办法

    关于python下安装PIL库遇到的问题及解决办法 关于python下安装PIL库遇到的问题及解决办法 :在下面这个网址下载pipllow(a replacement for PIL) www.lfd ...

  8. [转]安装PIL时注册表中找不到python2.7

    如果在win7x64安装python2.7的时候选择了all user,则安装PIL的时候会显示找不到python. 解决办法:复制下面的代码到一个.py文件并运行: # # script to re ...

  9. ubuntu14.04 安装PIL库出现OError: decoder jpeg not available 的解决方案

    出现 OError: decoder jpeg not available 的原因是,没有装JPEG的库,同时要支持png图片的话还要装 ZLIB.FREETYPE2.LITTLECMS的库文件. 先 ...

随机推荐

  1. sql server数据库中 INFORMATION_SCHEMA的用法

    1.查询数据库的所有表: select * from INFORMATION_SCHEMA.TABLES 2.查询表名为xxx的所有列的信息 select * from INFORMATION_SCH ...

  2. js、html中的单引号、双引号及其转义使用

    js.html中的单引号.双引号及其转义使用在js中对相关字符做判断或取值的时候很多情况下都会用到这些. ------ 在一个网页中的按钮,写onclick事件的处理代码,不小心写成如下:<in ...

  3. OpenGL ES之glUniform函数

    函数名: glUniform 功能: 为当前程序对象指定Uniform变量的值.(译者注:注意,由于OpenGL ES由C语言编写,但是C语言不支持函数的重载,所以会有很多名字相同后缀不同的函数版本存 ...

  4. HDU 1495 非常可乐 BFS

    题目大意:中文题不说了. 题目思路:我有同学用GCD数论写出来的代码很简洁,但是很抱歉,数论蒟蒻,我觉得比赛的时候我没办法推出.如果用BFS的话思路很简单的,就是6方向广搜,只不过稍微麻烦点.具体看代 ...

  5. UVALive 3027 并查集

    #include <cstdio> #include <queue> #include <cstring> #include <iostream> #i ...

  6. VJ16216/RMQ/线段树单点更新

    题目链接 /* 单点更新,用RMQ维护最大值,add对c[i]修改,或加,或减. 求[l,r]的和,用sum(r)-sum(l-1).即可. */ #include<cmath> #inc ...

  7. HUD 1541/BIT(数状数组)

    题目链接 /* 按从左到右,从下到上的顺序给出星星的坐标,计算出level为[0,n)的星星的个数. 星星的level为该星星左下边(包括自己正下方的星星,但是不包括自己)星星的个数. BIT模板题. ...

  8. python 第三章 字符串-例1

    1.字段宽度和精度 >>>'%.*s' % (10,'Gruido') '     Guido' >>>'%.-*s' % (10,'Gruido') 'Guido ...

  9. vbs打包exe工具

    工具下载:http://yunpan.cn/cceRRbszUt5MC  访问密码 66e2

  10. 转:Selenium借助AutoIt识别上传(下载)详解

    AutoIt目前最新是v3版本,这是一个使用类似BASIC脚本语言的免费软件,它设计用于Windows GUI(图形用户界面)中进行自动化操作.它利用模拟键盘按键,鼠标移动和窗口/控件的组合来实现自动 ...