Skip to content

Lernanta's Setup Install

dirkcuys edited this page Apr 24, 2012 · 47 revisions

Lernanta's Setup/Install

The main install/setup docs are based on the steps needed to install Lernanta in recent versions of Ubuntu. For install instructions on other environments look for more documentation in our wiki or contact us at the p2pu-dev mailing list.

Downloading the source code

If you just want to test Lernanta, you can download the latest code. If you are also going to contribute with fixes or the development of new features, please start the setup of you development environment by:

Downloading and Installing External Dependencies

The next step is to download and install Lernanta's external dependencies which varies depending on the OS you are using. The following are instructions for the latest versions of Ubuntu (please note that your system must be updated before following these instructions). If you are running another OS please look for instructions in other pages of our wiki or contact us at the p2pu-dev mailing list.

You need a few libraries and can grab them with these commands (the last two lines are needed for using sqlite, check other install pages for how to use lernanta with other db backends):

sudo apt-get install python-dev
sudo apt-get install python-setuptools
sudo apt-get install python-lxml
sudo apt-get install libssl-dev
sudo apt-get install python-imaging
sudo apt-get install python-m2crypto
sudo apt-get install gettext python-iso8601
sudo apt-get install make
sudo apt-get install swig

sudo apt-get install sqlite3
sudo apt-get install python-pysqlite2

Next, you'll need to install virtualenv, pip and virtualenvwrapper. They will allow you to install the rest of the external dependencies in an isolated Python environment. If you want to install the dependencies directly in your computer (not recommended for development) you will only need pip (remember to use sudo to install all the dependencies if this is the case).

sudo easy_install virtualenv
sudo easy_install pip
sudo pip install virtualenvwrapper

In order to configure virtualenvwrapper add the following lines to the ~/.bashrc file in your home directory.

export WORKON_HOME=$HOME/.virtualenvs
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
source /usr/local/bin/virtualenvwrapper.sh

You need to run those lines at least once by either typing them directly on the shell or by running:

bash

Now you can create the virtual environment by running:

mkvirtualenv lernanta --system-site-packages

You will notice that the shell prompt now includes the name of the virtual environment (called lernanta in this example) so you know you are working in it. In the future, when you need to use the already created virtual environment in another shell, you can run:

workon lernanta

To install the dependencies needed to use lernanta you can run:

pip install -r lernanta/lernanta/requirements/prod.txt

Other dependencies necessary for the development of lernanta can be installed by running:

pip install -r lernanta/lernanta/requirements/dev.txt

Configuring/Setting-Up Lernanta

In order to configure lernanta, please copy the configuration template and edit it to modify the database parameters and other settings (by default sqlite will be used so remember to edit this file if you are going to work with another of the database backends mentioned in our documentation). You can copy the template by running:

cp lernanta/lernanta/settings_local.dist.py lernanta/lernanta/settings_local.py

You must generate a new secret key for your lernanta setup. You can create a new key to assign to the SECRET_KEY variable in settings_local.py by running the following lines in the django shell:

from django.utils.crypto import get_random_string
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
print get_random_string(50, chars)

Create Database

After configuring lernanta the next step is to create the database used by it. If you use the default configuration, you will just need to create a lernanta.db database file by running:

make syncdb

Running Lernanta

Finally, start the development server by running the following line, and to take it for a spin by opening http://localhost:8000 in your browser.

python manage.py runserver

In order for the server to be accessible from another computer you can run the following line instead:

python manage.py runserver 0.0.0.0:8000

When you are trying out lernanta remember that (unless you change the configuration) emails will be printed in the shell where you ran the previous command. If you need to copy an url from these emails, be careful to removed any "=" symbols that may be added at the end of a line when the emails are displayed in the shell (e.g., remove the "=" from the url in the finish registration email which can cause a 404 page to be displayed).

Trouble Shooting

If you are new to virtual env the following videos could be of help: Python Dev Environment Screencasts.

If you follow this instructions and get an 'ImportError: No module named Image' try deleting your virtual environment, and created a new one, this time with the flag --no-site-packages. In the new environment install these packages with pip:

lxml
pil
m2crypto
iso8600

For more troubleshooting advice check out this thread in P2PU.

Clone this wiki locally