Saturday 29 January 2011

Install python 2.5 on ubuntu 10.04

So, you're a Python developer and like to use the 2.5.x track instead of the 2.6.x or the 3.x track. Well, never fear! Despite the fact that 2.5.5 is not installed in 10.04, or available in the repositories, you can still install it into your system. The following steps will show you how.
Open your terminal and type the following commands line by line:
sudo apt-get install build-essential gcc
cd Downloads
wget http://www.python.org/ftp/python/2.5.5/Python-2.5.5.tgz
tar -xvzf Python-2.5.5.tgz
cd Python-2.5.5
./configure --prefix=/usr/local/python2.5
make
make test
sudo make install
sudo ln -s /usr/local/python2.5/bin/python /usr/bin/python2.5
There you have it! Python 2.5.5 is installed. Now if you want to run it, you can type python2.5 from the terminal.


Source: Welcome to Ubuntu


Friday 28 January 2011

Install virtualenv and django, no-nonesense way

Install virtualenv

Installing virtualenv is easy on a Linux or Mac system, but the instructions that follow are Linux (Ubuntu, actually) specific. First you’ll need setuptools:

sudo apt-get install python-setuptools

Then we can easy_install virtualenv:
sudo easy_install virtualenv
We need to use sudo here because it has to install to a global location. Don’t worry, this is the last time we’ll need to do something as root.

Create your virtualenv

cd to wherever it is you keep your projects (for me, in ~/src), and run:
virtualenv --no-site-packages venv
In this instance I’ve chosen venv as the name for my virtual environment. The —no-site-packages command tells virtualenv not to symlink the global site packages into my local environment, just take the Python standard library. This is important, because it helps us avoid the dependency difficulties mentioned above.
At this stage you might want to add venv to your list of ignored files, as you don’t want it to be committed to source control:
echo "venv" >> .gitignore

Installing Django

Now, the trick with virtualenv is that it creates its own Python and easy_install binaries, which means you can install/run things specifically in your environment. Let’s install Django:
./venv/bin/easy_install django
And it’s done. easy. You might also want to install the MySQL bindings and IPython for ease of use:
./venv/bin/easy_install ipython python-mysql
To start a new Django project, you’ll note that a django-admin.py file will have been installed for you in the environment:
./venv/bin/django-admin.py startproject myapp
Obviously you can skip this step if you have an existing Django project.

Running Django

Now the last step, which is probably obvious by now, is to run Django’s runserver with the virtual Python binary:
cd myapp
../venv/bin/python manage.py runserver 0.0.0.0:8000
And you’re away!


Source: Bradley Wright