PyUserInput 在不同系统下的安装需要使用不同的依赖:
- Linux - Xlib (python-xlib)
- Mac - Quartz, AppKit
- Windows - pywin32, pyHook
1 安装Quartz依赖
安装命令:
pip install quartz
如果以上命令可以正常安装,则跳过以下步骤,如报错:
1.1 下载quartz-0.0.1.dev0.tar.gz安装包:
下载地址:
tips:以上下载地址是修改pip镜像为清华源后出现的😄
修改pip镜像为清华源步骤:
# pip环境更换
# pip若版本过低时,无法查看conf
pip3 install -U pip -i https://pypi.tuna.tsinghua.edu.cn/simple
# 创建文件夹
mkdir ~/.pip
# 创建配置文件
cd ~/.pip && touch pip.conf
# 写入
vim pip.conf
# 写入内容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
# 查看pip3源
pip3 config list
# or
pip config list
按上述修改pip镜像后再安装依赖quartz则出现quartz-0.0.1.dev0.tar.gz安装包下载地址:
1.2 解压quartz-0.0.1.dev0.tar.gz并修改setup.py
1)解压quartz-0.0.1.dev0.tar.gz
2)quartz-0.0.1.dev0文件夹内setup.py文件如下
找到以下行并修改:
install_requires=read_dependencies(“requirements.txt")
将其修改为:
install_requires=read_dependencies("quartz.egg-info/requires.txt")
1.3 quartz安装
回到quartz-0.0.1.dev0文件的父级目录,运行以下:
pip install -e quartz-0.0.1.dev0
完成标识:
2 安装AppKit依赖
安装过程中发现,PyUserInput所需的依赖库不叫AppKit这个名字,所以不是用pip install AppKit安装!
安装命令:
sudo pip install --upgrade --force-reinstall PyObjC PyObjC-core
完成标识:
3 安装PyUserInput
安装命令:
pip install PyUserInput
完成标识: