Saturday, June 30, 2018

Python installation in Ubuntu and Centos

To install python in ubuntu / centos follow these steps:

1) sudo apt-get install python (For UBUNTU)
1) yum install python  (For CENTOS)
 
2) You can verify python version by running python -V command
e.g.
root@Avinash:~# python -V
Python 2.7.14+
root@Avinash:~#

3) Now let us install pip utility.
    pip is a package management utility used to install and manage Python packages.
      run below command to install pip.
      apt-get install python-pip (For UBUNTU)
     yum install python-pip (For CENTOS)

4) Now, you can see the list of installed python packages by simply running any of the following command.
    i) pip list
    ii) pip freeze

e.g
root@Avinash:~# pip list
anyjson (0.3.3)
argcomplete (1.8.1)
argh (0.26.2)
attrs (17.2.0)


root@Avinash:~# pip freeze
adns-python==1.2.1
anyjson==0.3.3
argcomplete==1.8.1
argh==0.26.2
attrs==17.2.0


5) Now you can install any package using pip.
e.g
root@Avinash:~# pip install redis
Collecting redis
  Downloading https://files.pythonhosted.org/packages/3b/f6/7a76333cf0b9251ecf49efff635015171843d9b977e4ffcf59f9c4428052/redis-2.10.6-py2.py3-none-any.whl (64kB)
    100% |████████████████████████████████| 71kB 687kB/s
Installing collected packages: redis
Successfully installed redis-2.10.6
root@Avinash:~#

root@Avinash:~# pip freeze | grep redis
redis==2.10.6
root@Avinash:~#

You can check number of options provided by pip using pip help command.

Hurray!!!!
Python is installed. now we are ready to code in python

No comments:

Post a Comment