使用pip安装python库,命令行执行时报错:zsh: command not found

文章讲述了在Mac上使用oh-my-zsh时遇到pip安装的Python库如tidevice和airtest无法在命令行中使用的错误。问题根源是环境变量未正确配置。通过检查Python版本和.zshrc文件,发现需要在.zshrc中添加Python3的路径。最终,通过编辑.zshrc文件,将$HOME/Library/Python/3.9/bin添加到PATH环境变量中,然后重新加载配置解决了问题。
摘要由CSDN通过智能技术生成

mac上 已安装了oh-my-zsh,pip安装python库无法用命令行使用
报错 zsh: command not found: tidevice

➜  ~ tidevice
zsh: command not found: tidevice
➜  ~ airtest
zsh: command not found: airtest

一开始以为是系统安装多个python环境变量不统一的问题,但查找了python的版本,只有python3

➜  ~ which python
python not found
➜  ~ which python3
/usr/bin/python3

最后根据pip install时候的报错,给 .zshrc添加对应的环境变量后解决

➜  ~ pip3 install tidevice
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: tidevice in ./Library/Python/3.9/lib/python/site-packages (0.9.12)
Requirement already satisfied: Pillow in ./Library/Python/3.9/lib/python/site-packages (from tidevice) (9.3.0)

解决方案:
1.打开 ~/.zshrc

open ~/.zshrc

2.在zshrc文件里添加一行

export PATH="$HOME/Library/Python/3.9/bin:$PATH"

3.保存文件,并执行

source ~/.zshrc

4.命令行生效

➜  ~ tidevice
usage: tidevice [-h] [-v] [-u UDID] [--socket SOCKET] [--trace]
                {version,list,info,date,sysinfo,appinfo,applist,battery,screenshot,install,uninstall,reboot,shutdown,parse,watch,wait-for-device,launch,energy,kill,ps,relay,xctest,wdaproxy,syslog,fsync,crashreport,dumpfps,developer,pair,unpair,perf,set-assistive-touch,savesslfile,test}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值