2. 如何在 Ubuntu 上使用 Pip
1- 如何使用 Pip 搜索包
一旦你正确安装了 Pip 。
我们可以使用“search”命令搜索包,如下所示:
$pip3 search awx awx-exporter (0.2) - cli tool to create a portable/workstation compatible version of awx/tower inventories ansible-tower-cli (3.3.9) - A CLI tool for Ansible Tower and AWX. towerlib (3.2.8) - A python library to interface with ansible tower's (awx) api. awxapis (0.6) - Helper module for utilizing Ansible Tower/AWX Apis
2- 如何查找已安装的 Pip 包
要获取已安装软件包的列表,我们可以运行以下命令:
$pip3 list Package Version ---------------------- ------------ attrs 19.3.0 Automat 0.8.0 blinker 1.4 certifi 2019.11.28 chardet 3.0.4 Click 7.0 cloud-init 20.1 colorama 0.4.3
3- 如何使用 Pip 安装软件包
要安装最新版本的 Python 包,我们可以使用 install
命令。
假设我们要安装 pymetasploit3 包,如下所示:
$pip3 install pymetasploit3 Collecting pymetasploit3 Downloading pymetasploit3-1.0.2.tar.gz (18 kB) Collecting msgpack Downloading msgpack-1.0.0-cp38-cp38-manylinux1_x86_64.whl (303 kB) |████████████████████████████████| 303 kB 23.8 MB/s Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from pymetasploit3) (2.22.0) Building wheels for collected packages: pymetasploit3 Building wheel for pymetasploit3 (setup.py) ... done Created wheel for pymetasploit3: filename=pymetasploit3-1.0.2-py3-none-any.whl size=17048 sha256=923ae2a8be8629e20cc582f93991a84644096bb71364ae7ee1a62f9d48320eff Stored in directory: /root/.cache/pip/wheels/98/48/2d/a4166552fd5a5db76554b19e2dcd463d93283343aabac7d418 Successfully built pymetasploit3 Installing collected packages: msgpack, pymetasploit3 Successfully installed msgpack-1.0.0 pymetasploit3-1.0.2
要安装特定版本的软件包,我们可以使用以下命令:
$pip3 install PACKAGE_NAME==VERSION_NUMER
我们甚至可以使用包含运行特定 Python 项目所需版本的 pip 包列表的需求文件安装包:
$pip3 install -r requirements.txt
4- 如何使用 Pip 升级包
要升级 Python 包,我们可以运行以下命令:
$pip3 install --upgrade PACKAGE_NAME
5- 如何使用 Pip 删除包
要删除随 Pip 安装的任何软件包,请使用以下命令。
$pip3 uninstall PACKAGE_NAME
1. 在 Ubuntu 20 上安装 Pip
01 打开命令提示符并运行以下命令来安装 Pip:
$sudo apt install -y python3-pip
02 我们可以通过输入以下命令来验证 Pip 是否已正确安装:
$pip3 --version pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
03 要查看所有 Pip 命令和选项的列表,执行:
$pip3 --help
Pip 是安装和管理 Python 包的最佳工具之一。
Pip 是一个包管理系统,它简化了用 Python 编写的软件包的安装和管理,例如在 Python Package Index (PyPI) 中找到的软件包
本教程将展示如何在 Ubuntu 20.04 LTS 服务器上安装 Pip 并 安装和升级 Python 包。
日期:2020-06-02 22:18:21 来源:oir作者:oir