程序员开发实例大全宝库

网站首页 > 编程文章 正文

pip常用一些小技巧(pip命令的使用方法)

zazugpt 2024-08-27 23:56:54 编程文章 19 ℃ 0 评论

一、pip简介

下载链接:https://pypi.org/project/pip/,pip是python的包管理工具,python2.7/python3.4以上的版本都已经集成了该工具。

二、pip安装

1、windows下载及解压安装

在 https://pypi.org/project/pip/ 选择红框中的文件下载,下载完成后解压得到,CMD进入该目录下,输入python setup.py install命令进行安装,同时检查环境变量是否配置,如无则需要配置环境变量。

2、Linux下载及解压安装

在 https://pypi.org/project/pip/ 选择红框中的文件下载,进行解压tar -xzvf pip-21.2.4.tar.gz,然后进入解压文件,cd pip-21.2.4再安装python setup.py install。

三、pip install安装

1、安装包名

安装指定版本的包(pip install 包名==版本号)

如安装Django的1.8版本,pip install Django==1.8

2、其他常用的镜像源地址:

使用豆瓣下载(豆瓣:http://pypi.douban.com/simple/),在下载后面加上 - i"https://pypi.doubanio.com/simple/“ ,如:

  • pip install Robot Framework -i "https://pypi.doubanio.com/simple/"
  • pip install pytest -i "https://pypi.doubanio.com/simple/"
  • pip install pytest-html -i "https://pypi.doubanio.com/simple/"
  • pip install -U wxPython -i "https://pypi.doubanio.com/simple/"
  • pip install jsonpath -i "https://pypi.douban.com/simple"
  • pip install virtualenv -i "https://pypi.douban.com/simple"

使用阿里云下载(阿里云:http://mirrors.aliyun.com/pypi/simple/)

四、pip命令行

1、常用(安装及更新等)

list查看安装列表:

  • pip list
  • pip3 list
  • pip list --format columns

询可更新的包:

  • pip list --outdated

pip更新:

  • python.exe -m pip install --upgrade pip
  • python -m pip install -U pip
  • pip install --upgrade pip

查看版本:

  • pip --version或pip3 --version

卸载包:

  • pip uninstall 要卸载的包名

更新包:

  • pip install --upgrade 要更新的包名

批量更新包

  • pip install pip-review

2、pip参数解析

安装后,执行pip -h,显示如下(可以自行参考使用):

Commands:

  • install Install packages. 安装包
  • download Download packages.
  • uninstall Uninstall packages. 卸载包
  • freeze Output installed packages in requirements format. 按着一定格式输出已安装包列表
  • inspect Inspect the python environment.
  • list List installed packages. 列出已安装包.
  • show Show information about installed packages. 显示包详细信息.C:\Users\Administrator>pip show six
  • check Verify installed packages have compatible dependencies.
  • config Manage local and global configuration.
  • search Search PyPI for packages. 搜索包,类似yum里的search.
  • cache Inspect and manage pip's wheel cache.
  • index Inspect information available from package indexes.
  • wheel Build wheels from your requirements.
  • hash Compute hashes of package archives.
  • completion A helper command used for command completion.
  • debug Show information useful for debugging.
  • help Show help for commands. 当前帮助.

GeneralOptions:

  • -h,--help 显示帮助.
  • -V,--version 现实版本信息然后退出.

五、问题

问:解决ModuleNotFoundError: No module named 'pip'问题,

答:更新即可,执行python.exe -m pip install --upgrade pip

问:关于pip2和pip3共存问题的解决办法

答:******

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表