How to install Pip on CentOS 7

Pip is a package management system that simplifies installation and management of software packages written in Python such as those found in the Python Package Index (PyPI). Pip is not installed by default on CentOS 7, but the installation is pretty simple.

In this tutorial, we will walk through the steps required to install Python pip on CentOS 7 using the yum package manager and cover the basics of how to install and manage Python packages with pip.

When installing python modules globally you should prefer to install distribution provided python modules using yum because they are tested to work properly on CentOS 7. Use pip to install python modules globally only if there is no rpm package for the python module.

 

In most cases, you should use pip inside a virtual environment only. Python Virtual Environments allows you to install Python modules in an isolated location for a specific project, rather than being installed globally. This way you do not have to worry about affecting other Python projects.

Prerequisites

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

Installing pip on CentOS

To install pip on your CentOS machine, follow these steps:

1. Add the EPEL Repository

Pip is not available in CentOS 7 core repositories. To install pip we need to enable the EPEL repository:

 

sudo yum install epel-release

Copy

2. Install pip

Once the EPEL repository is enabled we can install pip and all of its dependencies with the following command:

sudo yum install python-pip

Copy

3. Verify Pip installation

To verify that the pip is installed correctly run the following command which will print the pip version:

pip --version

Copy

The version number may vary, but it will look something like this:

pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

Copy

Install development tools

Development tools are required for building Python modules, you can install them with:

sudo yum install python-devel
sudo yum groupinstall 'development tools'

Copy

Managing Python Packages With PIP

In this section, we will go through a few useful basic pip commands. With pip, we can install packages from PyPI, version control, local projects and from distribution files. Usually, you will install packages from PyPI.

 

Let’s say we want to install a package named twisted, we can do that by issuing the following command:

pip install twisted

Copy

twisted is an asynchronous networking framework written in Python.

To uninstall a package run:

pip uninstall twisted

Copy

To search packages from PyPI:

pip search "twisted"

Copy

To list installed packages:

 

pip list

Copy

To list outdated packages:

pip list --outdated

Copy

Conclusion

You have successfully installed pip on your CentOS 7 system and you learned how to easily install and uninstall Python modules with pip. You can also check our guide about how How to install Python 3 with Pip 3 on CentOS 7.

link: https://linuxize.com/post/how-to-install-pip-on-centos-7/

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值