• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

pywin32找不到python怎么解决

python 搞java代码 3年前 (2022-05-21) 40次浏览 已收录 0个评论

1、检查一下注册表是否存在python其它版本的信息

方法:

(1)在命令行中输入regedit打开注册表

(2)在HKEY_CURRENT_USERSoftware中找一下是否存在python注册信息,如果存在,检查一下是否是python27版本,且是否包含下面两个节点。

再检查一下其对于的安装路径是否正确。如果不知道如何检查,可以把python节点信息右击选择删除。如果python注册信息不存在,这里就不用操作了。

相关推荐:《Python入门教程》

2、新建register.py文件,复制如下代码保存在D盘根目录下,cmd命令行运行 python register.py,当输出“python 2.7 is already registered”就ok了。

(python27使用正常,无需修改任何内容)

#
# 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/[email protected]/ 
msg10512.html
 
import sys
from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
 
regpath = "SOFTWAREPythonPythoncore\%s" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%sLib;%sDLLs" % (
    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()

www#gaodaima.com来源gaodai$ma#com搞$$代**码网搞代码

3、执行后再检查一下注册表。python27的注册信息已经存在了。

4、再次安装pywin32-220.win32-py2.7.exe,结果安装成功。

来源:搞代码网:原文地址:https://www.gaodaima.com


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:pywin32找不到python怎么解决

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址