欢迎各位兄弟 发布技术文章
这里的技术是共享的
如果需要截图,要使用下面这个关键字,但是运行后会发现报错
所以还需要安装PIL
安装方法:
地址:http://www.pythonware.com/products/pil/
安装遇到问题
安装PIL-1.1.7.win32-py2.7的时候,不能再注册表中识别出来python2.7
方法:新建一个register.py 文件,把一下代码贴进去,保存
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim L?w for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
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_LOCAL_MACHINE, regpath)
except EnvironmentError:
try:
reg = CreateKey(HKEY_LOCAL_MACHINE, 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()
源文档 <http://effbot.org/zone/python-register.htm>
(代码来自:http://effbot.org/zone/python-register.htm)
然后打开IDLE
将代码copy进入new window里面,然后保存,再执行
按F5执行即显示:
显示"python 2.7 is already registered"
再安装setuptools的时候,就能自动识别出来python2.7了。
win7是 64的原因,在安装python(32位)时,如果选择只为当前用户,以上问题是不会出现的,如果选择所有用户,那就用上面的方法解决吧。
如果你是开着ride的时候安装的,记得安装完成之后重启ride
64位系统下如何安装?看一下下面这个文章,
参考链接:http://blog.csdn.net/zxia1/article/details/8254113
下载链接:http://www.lfd.uci.edu/~gohlke/pythonlibs/
在PIL的官方网页上,给出了很多PIL的版本,当选择Win32版本在Windows 7下安装时,会报出无法找到Python的提示,即使正确安装了Python 2.7。在网上查阅后,有人如下回答:
问题:
在64位Win7下安装PIL库,提示注册表中找不到Python2.7(肯定是有的)。
原因:
PIL官方http://www.pythonware.com/products/pil/提供的PIL二进制安装库都是32位的。
64位程序和32位程序检测注册表的位置是不一样的:
64-bit: HKLM|HKCU\SOFTWARE\
32-bit: HKLM|HKCU\SOFTWARE\wow6432node\
我安装的是Python2.7 x64版,所以相关信息是在 HKLM|HKCU\SOFTWARE\下面,32位程序在HKLM|HKCU\SOFTWARE\wow6432node\下面找Python安装信息,肯定是找不到了。
解决:
幸好有人提供了非官方的64位库(官方源码编译版)。
http://www.lfd.uci.edu/~gohlke/pythonlibs/
在提供的网址下,下载PIL 64位的版本,果然可以用了。
注:在linux下安装PIL for Python3.x,可以到https://github.com/sloonz/pil-py3k下载相应版本。
收藏这个地址,里面很多pythonlibs
http://www.lfd.uci.edu/~gohlke/pythonlibs/
如果想取消注册:
Unregistering the interpreter
If you need to reverse the above, you can add the following function to the script (code provided by Martin Lamar):
Unregister a Python Interpreter
def UnRegisterPy():
try:
reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
except EnvironmentError:
print "*** Python not registered?!"
return
try:
DeleteKey(reg, installkey)
DeleteKey(reg, pythonkey)
DeleteKey(HKEY_LOCAL_MACHINE, regpath)
except:
print "*** Unable to un-register!"
else:
print "--- Python", version, "is no longer registered!"
来自 http://lijunwei1228ok.blog.163.com/blog/static/9738379720140231713138/