Labels

Sunday, May 5, 2013

How to Install Python 2.7

Download Python : Below the following commands to download and extract Python 2.7 to your hosting account.

# mkdir ~/python
# cd ~/python
# wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
# tar zxfv Python-2.7.2.tgz
# find ~/python -type d | xargs chmod 0755
# cd Python-2.7.2


Install Python : When extracted finish you can use the following commands to configure and install Python.

# ./configure --prefix=$HOME/python
# make
# make install
Modify the .bashrc
For your local version of python to load you will need to add it to the .bashrc file.
 # vim ~/.bashrc
Press i

Enter:
    export PATH=$HOME/python/Python-2.7.2/:$PATH
   
Write the changes and close vim:
    :wq

Press Enter
# source ~/.bashrc
put your Python file in any location like : /opt/Python
goto Python  folder and run the file

# cd /opt/Python
# Python  filename.py
Thanks