To install python libraries/packages/modules in CentOS, there are two ways to do it
1) Using yum
2) Using pip (Python Package Index) - The python package pip provides a tool named pip-python for installing and managing Python packages
To install a python library/package/module using yum
For this purpose, EPEL(Extra Packages for Enterprise Linux) repo for yum need to be installed first.
1) Find the version of Linux
# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.4 (Final)
Release: 6.4
Codename: Final
1) Using yum
2) Using pip (Python Package Index) - The python package pip provides a tool named pip-python for installing and managing Python packages
To install a python library/package/module using yum
For this purpose, EPEL(Extra Packages for Enterprise Linux) repo for yum need to be installed first.
1) Find the version of Linux
# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.4 (Final)
Release: 6.4
Codename: Final
2) Download and install the epel repo rpm relevant for the above version
a) # wget http://mirror-fpt-telecom.fpt.net/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
b) # yum install epel-release-6-8.noarch.rpm
Once the EPEL yum repo is installed. any python package/module/library can be installed using yum like any other linux package
Say, for example, if I want to install feedparser python library/package/module, it can done as follows
# yum install python-feedparser
To install a python library/package/module using pip
1) pip is a python module. So, first python pip module need to be installed. To install the python module, EPEL repo on CentOS need to be enabled(How to enable EPEL repo is mentioned in above step).
2) Once EPEL repo is enabled, install pip as follows
# yum install python-pip
This provides us a tool called pip-python, using which, the following can be done
a) Install a package
# pip-python install packagename
b) Uninstall a package
# pip-python uninstall packagename
c) To list all installed python packages/modules/libraries
# pip-python freeze
d) To get help with pip-python command
# pip-python help
No comments:
Post a Comment