报错 no module named win32api 的解决方案 以及python添加注册表方法
2015-12-31 09:55
661 查看
解决方案:
原因是缺少win32,到 http://sourceforge.net/projects/pywin32/files/找到对应的版本进行下载,直接安装即可
window下,python安装两个版本,其中一个版本的注册表会被覆盖。要执行下面的脚本来添加测试表
# # 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 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_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()
Windows 7 64位下安装了 Python 的64位安装包,再安装其他预编译的Library就会有找不到Python的错误。 应该是有些Key没有加入到注册表中,需要运行下面的脚本修正。
该脚本用于python2.x,要注册python3.x版本,要修改
from _winreg import *为
from winreg import *
原因是_winreg 改成了winreg
来源:http://blog.csdn.net/olanlanxiari/article/details/48196255
来源:http://www.cnblogs.com/min0208/archive/2012/05/24/2515584.html
相关文章推荐
- python学习笔记(一)---python简介
- 我们一起学python-helloworld
- Python标准库11 多进程探索 (multiprocessing包)
- win8.1+python34安装Numpy
- MySQL Connector/Python 安装、测试
- python安装setuptools
- python 安装 setuptools Compression requires the (missing) zlib module 的解决方案
- It's possible that the above module doesn't match the current version of Python
- Python基础第三篇
- 用python爬取文章链接并分类
- python实现爬虫统计学校BBS男女比例(一)
- python实现爬虫统计学校BBS男女比例之多线程爬虫(二)
- python实现爬虫统计学校BBS男女比例之数据处理(三)
- 基于python的Tkinter实现一个简易计算器
- python实现颜色空间转换程序(Tkinter)
- 简单实现python爬虫功能
- python-68:BS4获取多个标签的文本
- python-69:find() 和 find_all()
- python+selenium
- Flask Web开发背景介绍及环境配置