Python pip 环境管理学习

pip 概述

  • pip 是 Python 包管理工具
    • python2 的 2.7.9 版本开始自带
    • python3 的 3.4 版本开始自带
  • https://pypi.org/ 托管了大量流行的 Python 包

pip 常用命令

 
功能 指令
查看 pip 版本 pip -V
查看帮助文档 pip help
查看包列表 pip list
导出包列表 pip freeze
安装 pip install 包名
升级 pip install -U 包名
卸载 pip uninstall 包名

 

pip 安装包

  • 普通安装
  • 指定版本
  • 从文件中安装
# 默认安装最新版本
$ pip install pytest

# 执行版本
$ pip install pytest==6.2.0

# 从文件清单中批量安装,可先用pip freeze 导出安装包到这个文件requirments.txt $ pip install -r requirments.txt # 文件格式 pytest==6.2.0 Faker==9.3.1 selenium==3.14.1 

 

pip 升级包

  • 升级已安装的 Python 包
$ pip install -U pytest

pip 卸载包

  • 卸载 Python 包
# 卸载包

$ pip uninstall pytest

pip 使用镜像加速

  • pip install -i 镜像源

国内常用源

  • 阿里源:https://mirrors.aliyun.com/pypi/simple/
  • 清华源:https://pypi.tuna.tsinghua.edu.cn/simple/
  • 豆瓣源:http://pypi.douban.com/simple/

 

# 使用镜像

pip install pytest -i https://pypi.douban.com/simple

 

 

posted @   lms21  阅读(72)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示