Python - Ubuntu: Questions and Answers (2014)

Ubuntu: Questions and Answers (2014)

Python

Skip to questions, Wiki by user ændrük

Python is a general purpose language which can be used for anything from quick scripting jobs to fully object-oriented GUI programs.

Python is designed to have readable source code. As such, code blocks are delimited by indentation instead of the braces used in many other languages. Python is one of few programming languages to have significant white space.

Unlike C-like languages, Python is generally not compiled and is instead an interpreted language. The most common interpreter is CPython, which is written in C. Other interpreters are PyPy, which is written in Python and Jython, which is written in Java.

From http://hg.python.org/peps/rev/76d43e52d978 (PEP 373, Python 2.7 Release Schedule):

The End Of Life date (EOL, sunset date) for Python 2.7 has been moved five years into the future, to 2020. This decision was made to clarify the status of Python 2.7 and relieve worries for those users who cannot yet migrate to Python 3.


Questions

Q: How do I install python 2.7.2 on Ubuntu?

Tags: python (Next Q)

I want to install python 2.7.2.tgz on Ubuntu, downloaded from http://python.org/download/.

Is this a correct way to install :

./configure

make

make install

If not , how can I do that?

Tags: python (Next Q)

User: mohammad


Answer by achu

First, install some dependencies:

sudo apt-get install build-essential

sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Then download using the following command:

cd ~/Downloads/

wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz

Extract and go to the dirctory:

tar -xvf Python-2.7.5.tgz

cd Python-2.7.5

Now, install using the command you just tried:

./configure

make

sudo make install


Answer by brousch

Unless you really have a burning desire to compile it yourself, the preferred way is to use the DeadSnakes PPA to install versions of Python that aren't included by default:

sudo add-apt-repository ppa:fkrull/deadsnakes

sudo apt-get update

sudo apt-get install python2.7


Tags: python (Next Q)


Q: How can I install Python 2.6 on 12.04?

Tags: python

According to https://wiki.ubuntu.com/PrecisePangolin/ReleaseNotes/UbuntuDesktop "Python 2.6 is no longer available for install".

I need to support legacy software that runs only on Python 2.6. How can I install Python 2.6 on Ubuntu 12.04?

Tags: python

User: d3vid


Answer by localhost

I'm using a PPA: https://launchpad.net/~fkrull/+archive/deadsnakes

Install the PPA:

sudo add-apt-repository ppa:fkrull/deadsnakes

Run Update:

sudo apt-get update

Install your flavor:

sudo apt-get install python2.6 python2.6-dev


Answer by andrewjesaitis

Check out pythonbrew. It does a great job of managing multiple python versions and enviroments. It builds each version of python from source, but does so in a user friendly way. After you install it just run:

pythonbrew install 2.6

pythonbrew switch 2.6

Then you can use it with virtualenv to create a virtual enviroment with whatever frameworks and libraries you need without having to worry about conflicts.


Tags: python


Q: How do I create a deb package for a single python script?


Q: How do I install python 2.7.2 on Ubuntu?


Q: How can I install Python 2.6 on 12.04?


Q: Is #!/bin/sh read by the interpreter?