Installing Zoook on Ubuntu II: Python and Django
In this part: Installing Zoook on Ubuntu II; we’ll head on to the installation of Python and Dango on Ubuntu 11.10 and verify its working.
Este artículo también está disponible en castellano.
Table of Contents
1 Install Python
The default Python interpreter on Ubuntu 11.10 is 2.7.2. To verify that this is the version on your system execute:
$ python
Find out the version of your Python installation.
The message indicates that the version 2.7.2 is installed.
To exit the Python interpreter execute a
>>> quit()
In the rare case that there is no Python on your system, install it via
$ sudo apt-get install python
2 Install Django
Install all dependencies needed by Django:
$ sudo apt-get install python-dev python-psycopg2
You can install Django in three different ways:
- via the package management system of your distribution,
- fetching the latest stable version from the website, or
- download the development version from their repositories.
2.1 Installation via the package management system
The installation via the package management system is as simple as
$ sudo apt-get install python-django
2.2 Installing the last stable version from the website
Surf to the download section of the Django site and check for the latest stable version. That was 1.3.1 as of this writing (8th of February 2012).
$ cd ~ $ tar xvzf Django-1.3.1.tar.gz $ mv Django-1.3.1 django-src
This way you’ll find the source code in the directory ~/django-src
. The next step is to pass this information to Python. Locate the site-packages of your Python installation:
$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
Locate the site-packages of your Python installation.
which indicates that your site-package directory is /usr/lib/python2.7/dist-packages
. In this directory you’ll have to add the route to the Django sources:
$ echo '/home/roberto/django-src' | sudo tee -a /usr/lib/python2.7/dist-packages/django.pth
This creates the file /usr/lib/python2.7/dist-packages/django.pth
with the path to your Django installation.
To make a live a bit more comfortable, create a symbolic link to django-admin.py:
$ sudo ln -s /home/roberto/django-src/django/bin/django-admin.py /usr/local/bin
This way you can use django-admin.py
in every place of the file system instead of executing the script by its absolute path ~/django-src/django/bin/django-admin.py
.
3 Verify the installation
Check that Python can find the Django modules:
$ python >>> import django >>> print django.get_version()
Check that Python finds Django.
This indicates that Python detected Django in its 1.3.1 version.
3.1 Create a Django test project
We are going to create a Django test page in order to verify that everything is working fine. At first create a new directory for this:
$ mkdir ~/django-projects $ cd ~/django-projects
In this case the directory is located in the home directory of the user and has the name django-projects
. Now, create a test project in this category:
$ django-admin.py startproject testdjango
Change to the directory of the project and start the Django server:
$ cd testdjango $ python manage.py runserver
Successfully started Django server.
The server started up correctly and is waiting for connections on port 8000 (http://127.0.0.1:8000/).
Now, we could create a database in PostgreSQL and verify the connection with the project. But, given the aim of this article (install Zoook) we’re going into the details of the database access when configuring Zoook.
You could find more information about Installing Zoook on Ubuntu II in our web: https://openerpspain.com/odoo/