zoukankan      html  css  js  c++  java
  • 安装pywin32出现--Python version 3.x required, which was not found in the registry

    这两天安装pywin32时出现了这个问题

    双击.exe文件进入安装界面,然后点击下一步,它会自动定位你的python安装在什么地方,但是我的安装过程中未自动定位到python安装位置,并显示显示:

    安装pywin32出现--Python version 3.6 required, which was not found in the registry

    百度了好久,就执行个python脚本即可解决

    1、新建一个register.py文件(我将其放在pywin32同一个文件下),双击打开

    python3将以下代码粘贴并保存

     1 from __future__ import print_function
     2  
     3  
     4 import sys
     5  
     6 try:
     7     from winreg import *
     8 except ImportError:
     9     from _winreg import *
    10  
    11 # tweak as necessary
    12 version = sys.version[:3]
    13 installpath = sys.prefix
    14  
    15 regpath = "SOFTWARE\Python\Pythoncore\{0}\".format(version)
    16 installkey = "InstallPath"
    17 pythonkey = "PythonPath"
    18 pythonpath = "{0};{1}\Lib\;{2}\DLLs\".format(
    19     installpath, installpath, installpath)
    20  
    21  
    22 def RegisterPy():
    23     try:
    24         reg = OpenKey(HKEY_CURRENT_USER, regpath)
    25     except EnvironmentError as e:
    26         try:
    27             reg = CreateKey(HKEY_CURRENT_USER, regpath)
    28             SetValue(reg, installkey, REG_SZ, installpath)
    29             SetValue(reg, pythonkey, REG_SZ, pythonpath)
    30             CloseKey(reg)
    31         except:
    32             print("*** Unable to register!")
    33             return
    34         print("--- Python", version, "is now registered!")
    35         return
    36     if (QueryValue(reg, installkey) == installpath and
    37         QueryValue(reg, pythonkey) == pythonpath):
    38         CloseKey(reg)
    39         print("=== Python", version, "is already registered!")
    40         return
    41     CloseKey(reg)
    42     print("*** Unable to register!")
    43     print("*** You probably have another Python installation!")
    44  
    45 if __name__ == "__main__":
    46     RegisterPy()

    2、保存之后进入cmd,切换到存储该py文件的目录,执行python registed.py即可重新运行exe文件进行pywin32的安装。

    成功时的界面:然后点击下一步即可

  • 相关阅读:
    vue2.0:(三)、项目开始,首页入门(main.js,App.vue,importfrom)
    vue2.0:(二)、mock数据
    sublime text less安装踩坑图文讲解(less无法生成css)
    vue2.0:(一)、vue的安装和项目搭建(以外卖app项目举例)
    移动端开发(二)(初级入门)
    移动端开发(一)(初级入门)
    git与GitHub(二)
    git与GitHub(一)
    项目心得1
    MIPS(极路由1s[mt7620a])平台OpenWrt路由器系统内的Go应用程序开发
  • 原文地址:https://www.cnblogs.com/pinpin/p/9881459.html
Copyright © 2011-2022 走看看