我为这个问题得到的解决方案是
我发现将Python添加到注册表中,以下脚本适用于python v 2.0及更高版本:注册Python解释器
## script to register Python 2.0 or later for use with win32all # and other extensions that require Python registry settings## written by Joakim Low for Secret Labs AB / PythonWare## source:# http://www.pythonware.com/products/works/articles/regpy20.htmimport sysfrom _winreg import *# tweak as necessaryversion = sys.version[:3]installpath = sys.prefixregpath = "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()
用任何名称保存它。从python解释器运行它,就这样!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)