如何在 Ubuntu 18.04 LTS 上安装 Pip

[ad_1]

在本教程中,我们将向您展示如何在您的 Ubuntu 18.04 LTS 上安装 Pip。 对于那些不知道的人,Pip 命令是一个用于安装和管理 Python 包的工具,例如 Python 包索引中的那些。 在 pip 的帮助下,您还可以安装特定版本的包。 最重要的是,pip 具有管理包的完整列表和相应版本号的功能,可以通过“需求”文件来实现。 它执行与 easy_install 相同的基本工作,但具有一些额外的功能。

本文假设您至少具备 Linux 的基本知识,知道如何使用 shell,最重要的是,您将网站托管在自己的 VPS 上。 安装非常简单,假设您在 root 帐户下运行,如果不是,您可能需要添加 ‘sudo‘ 到命令以获取 root 权限。 我将向您展示在 Ubuntu 18.04 LTS (Bionic Beaver) 服务器上逐步安装 Pip Python。

在 Ubuntu 18.04 LTS Bionic Beaver 上安装 Pip

步骤 1. 首先,通过运行以下命令确保所有系统包都是最新的 apt-get 终端中的命令。

sudo apt-get update
sudo apt-get upgrade

步骤 2. 在 Ubuntu 18.04 LTS 上安装 PIP。

使用安装 pip apt-get 命令:

apt install python-pip

安装完成后,您可以使用以下命令验证它是否成功:

pip --version

步骤 3. 基本用法 pip 命令。

安装 python-pip 包后,pip 命令将在系统上可用。 pip 命令有多个可用选项:

要安装新的 python 包类型:

pip install Package_Name

要卸载通过 pip 类型安装的 python 包:

pip uninstall Package_Name

要搜索 python 包类型:

pip search Package_Name

有关更多 Pip 选项和使用示例,您可以使用 –help 标志:

[[email protected] ~]# pip --help

Usage:   
  pip <command></command> [options]

Commands:
  install                     Install packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  zip                         DEPRECATED. Zip individual packages.
  unzip                       DEPRECATED. Unzip individual packages.
  bundle                      DEPRECATED. Create pybundles.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output.
  --log-file            Path to a verbose non-appending log, that only logs failures. This
                              log is active by default at /home/sharad/.pip/pip.log.
  --log                 Path to a verbose appending log. This log is inactive by default.
  --proxy              Specify a proxy in the form [user:[email protected]]proxy.server:port.
  --timeout              Set the socket timeout (default 15 seconds).
  --exists-action     Default action when a path already exists: (s)witch, (i)gnore,
                              (w)ipe, (b)ackup.
  --cert                Path to alternate CA bundle.
[[email protected] ~]#

恭喜! 您已成功安装 Pip。 感谢您使用本教程在 Ubuntu 18.04 LTS Bionic Beaver 系统上安装 Pip Python。 如需更多帮助或有用信息,我们建议您查看 Python 官方网站.

[ad_2]

Related Posts