1 import sys 2 3 from _winreg import * 4 5 # tweak as necessary 6 version = sys.version[:3] 7 installpath = sys.prefix 8 regpath = "SOFTWAREPythonPythoncore\%s\" % (version) 9 installkey = "InstallPath" 10 pythonkey = "PythonPath" 11 pythonpath = "%s;%sLib;%sDLLs\" % ( 12 installpath, installpath, installpath 13 ) 14 15 def RegisterPy(): 16 try: 17 reg = OpenKey(HKEY_CURRENT_USER, regpath) 18 except EnvironmentError as e: 19 try: 20 reg = CreateKey(HKEY_CURRENT_USER, regpath) 21 SetValue(reg, installkey, REG_SZ, installpath) 22 SetValue(reg, pythonkey, REG_SZ, pythonpath) 23 CloseKey(reg) 24 except: 25 print "*** Unable to register!" 26 return 27 print "--- Python", version, "is now registered!" 28 return 29 if (QueryValue(reg, installkey) == installpath and 30 QueryValue(reg, pythonkey) == pythonpath): 31 CloseKey(reg) 32 print "=== Python", version, "is already registered!" 33 return 34 CloseKey(reg) 35 print "*** Unable to register!" 36 print "*** You probably have another Python installation!" 37 RegisterPy()
将以上代码运行一下注册一下现有的路径即可安装PIL了
PIL下载地址:http://pythonware.com/products/pil/