Python 2.x – 3.x installation and setup

1. Python versions
Currently there are two major versions of Python being maintained (details are beyond the scope of this document):

  • Version 2.7 is the older and is said that the community will maintain it indefinitely or until they run out of cookies.  🙂
  • Version 3.4 is the current version that is pushing forward ever so steadily.

2. Downloading and installing python

Since Python can be run on all major operating systems, there are many different ways to download and install it. Lets explore some general ways this can be accomplished.

Ubuntu (linux) comes preloaded with python; however if a new one is needed you could use the following methods (there are many other ways):

Package manager:

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.7

or

Download and install the source from either the:

  • First lets update:
    sudo apt-get install build-essential checkinstall
    sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
  • Now download:
    from either here.
    or with wget http://python.org/ftp/python/2.7.x/Python-2.7.x.tgz
  • Now Uncompress: tar -xvf Python-2.7.x.tgz
  • Finally install:
    ./configure
    make
    checkinstall

Now in order to use this version of Python we have just installed we will probably need to add its location to our PATH. In MacOS X or Linux operating systems you will need to edit the ~/.profile or ~/.bashrc file and added the following line:
export PATH=$PATH:/path/to/Python/programs
Obviously “/path/to/Python/programs” is the location where you just installed python into.

!IMPORTANT! on *nix system after you have saved your changes and exit the editor you will need to type one of these commands:

  • $ source ~/.bashrc
  • $ . ~/.bashrc
  • $ exec bash(not sure if this works on Mac)

which update your environment with the new changes.

Next post will be about how we actually use python regarding interpreters and shells. Coming soon…

Advertisements

One comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s