如何在 CentOS 7 上安装 Pip

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

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

在 CentOS 7 上安装 Pip

第 1 步。首先,让我们首先确保您的系统是最新的。

yum clean all yum install epel-release yum -y update

步骤 2. 安装 Pip。

方法一。

使用安装 pip Yum 命令:

yum -y install python-pip

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

pip -V

方法2。

使用 Curl 和 Python 安装 Pip:

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

现在安装 点子通过使用以下命令:

python get-pip.py

安装完成后,您可以验证安装:

pip -V

步骤 3. 如何使用 pip 命令。

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

要安装新的 python 包类型:

pip install packageName

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

pip uninstall packageName

要搜索 python 包类型:

pip search packageName

有关更多 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。 感谢您使用本教程在 CentOS 7 系统上安装 Pip Python。 如需更多帮助或有用信息,我们建议您查看 Python 官方网站.

Save