编程语言
首页 > 编程语言> > python pyHook安装

python pyHook安装

作者:互联网

Hook安装

哇 这东西可真费劲  主要有pyhook和pyhook3 两种 每个都要根据系统版本和python版本 分成各种小版本

具体安装

一.可以在cmd 中输入 pip install pyhook 来尝试自动在线安装 一般都不行

二.可以去https://www.lfd.uci.edu/~gohlke/pythonlibs/ 中寻找自己喜欢的版本 

然后下载

在cmd中输入  pip install 将刚下载的*.whl文件拖入cmd 回车安装

三.去https://sourceforge.net 里面搜 或许有自动安装包 不过python有注册表问题 安装中会报错 “没有找到该python版本” 复制下面的代码 保存为*.py 运行一下即好

#
# 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()

四.如果安装了多个版本python 在cmd时只会显示一种,这样pip安装不能指向所需要的版本,就需要更改环境变量Path,删掉不需要的版本即可,同时一定记得备份该数据。如果在更改完使用一些基本cmd命令无效,如ipconfig 需要在环境变量Path头部添加《c:\windows\system32;》 去掉书名号 

----

以上也适用于win32 或者其他包的安装。

标签:installpath,python,pyHook,Python,版本,安装,reg
来源: https://www.cnblogs.com/moshuixiong/p/11334446.html