pip 相关命令
pip freeze >requirements.txt # 导出依赖包列表
pip install -r requirements.txt # 从依赖包列表中安装
pip install -c constraints.txt # 确保当前环境软件包的版本(并不确保安装)
pip list # 查询当前环境安装的所有软件包
pip search pkg # 查询 pypi 上含有某名字的包
pip list --outdated # 查询当前环境中可升级的包
pip show pkg # 查询一个包的详细内容
限定版本进行安装
pip install pkg==2.1.2 # 所安装的包的版本为 2.1.2
pip install pkg>=2.1.2 # 所安装的包必须大于等于 2.1.2
pip install pkg<=2.1.2 # 所安装的包必须小于等于 2.1.2
指定代理服务器安装
& C:/Users/[user]/AppData/Local/Programs/Python/Python312/python.exe -m pip --proxy http://usr:pswd@ip:port install pkgname
win永久换源方法
手动建目录 C:\Users\wangjiangjun.fnst\AppData\Roaming\pip\pip.ini
或者 设置一下可自动生成
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
阿里云
https://ai-foundation-chat-dot-ai-web-ui-prod.an.r.appspot.com/
中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban)
https://pypi.douban.com/simple/
清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学
https://pypi.mirrors.ustc.edu.cn/simple/
官方源
https://pypi.python.org/simple