适用于Windows,PIP更新Python库bat脚本

PIP更新Python库的bat脚本

复制粘贴到新建的.bat文件即可,PIP安装在C盘需要管理员权限运行。

@echo off
rem 设置编码为GBK,防止乱码
chcp 936>nul
rem trust-host选项和https协议有关,使用未加密的http协议需要此设置
set trusthost=mirrors.aliyun.com
rem index-url选项指明更新源
set indexurl=http://mirrors.aliyun.com/pypi/simple/
rem 判断是否安装python
python -V >nul 2>nul
if %errorlevel%==0 (
	echo 安装了python
	goto checkpip
)
echo 请检查是否设置python环境变量
goto end
rem 是否安装了pip
:checkpip
pip -V >nul 2>nul
if not %errorlevel%==0 (
	echo 请检查是否设置pip环境变量
	goto end
)
echo 安装了pip
rem 使用for循环更新有新版本的python包,跳过前两行提示信息,取第一列包名称
for /f "skip=2 tokens=1 delims= " %%i in ('pip list --outdated --trusted-host %trusthost% --index-url %indexurl%') do (
	python -m pip install --upgrade %%i --trusted-host %trusthost% --index-url %indexurl%
)
echo 更新完毕!按任意键退出...
:end
pause >nul

非常简单的一个脚本,很粗糙但是能用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值