博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python依赖包exe文件安装问题
阅读量:6982 次
发布时间:2019-06-27

本文共 1654 字,大约阅读时间需要 5 分钟。

hot3.png

在使用python的exe程序安装依赖包的时候,经常会出现类似于下面的错误: python version 2.7 required,which was not found in the registry

可以使用如下代码解决该问题:

## 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/distutils-sig@python.org/msg10512.html import sys from _winreg import * # tweak as necessaryversion = 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_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()

转载于:https://my.oschina.net/hgfdoing/blog/532037

你可能感兴趣的文章
线性回归——最小二乘法_实例(二)
查看>>
POJ2866:Who Gets the Most Candies?(线段树 + 反素数 + 约瑟夫环)
查看>>
微信支付开发(12) 认清微信支付v2和v3
查看>>
k8s学习笔记之三:k8s快速入门
查看>>
SpringBoot慕课学习-SpringBoot开发常用技术整合
查看>>
即将毕业的一些感想
查看>>
iframe 解决跨域问题
查看>>
The existing index has no NexusIndexer descriptor
查看>>
界面收缩和扩展
查看>>
Selenium学习(14) 判断元素expected_conditions
查看>>
Linux命令之tcpdump
查看>>
(更新)Java + 腾讯企业邮箱 + javamail + SSL 发送邮件
查看>>
组合数据类型综合练习
查看>>
php回调函数callback函数实例
查看>>
示波器测量电源的纹波
查看>>
自定义ListBox,实现单多选切换(复选框)
查看>>
软件测试2019:第八次作业
查看>>
Centos下安装FTP并进行虚拟用户访问方式配置
查看>>
python day09
查看>>
拆系数FFT及其部分优化
查看>>