This course will become read-only in the near future. Tell us at if that is a problem.

Create development environment

Setting up the enviroment:

We are using vagrant for our development environments. You can find the instructions to get up and running here.

If for some reason you don't want to use vagrant or you prefer to not use a virtual machine, you can find the old setup instructions here.

Once you are done setting up, the virtual machine should already be running lernanta on port 8001. Create an account and login.


You can communicate with other P2PU developers using this course or via our mailing list.

If you would like to be involved in other parts of the P2PU project, there are also the community mailing list.

Writing Task:

Then, let us know how it went below (or on your blog and link to that below). Run into any problems? How did you solve it? What worked well with the documentation and what didn't? What suggestions do you have for others starting to develop on Lernanta?

Diskutera uppgift

  • Tim Gaudette sa:

    updated virtual box to 4.2 because it has been a while since I used it

    installed vagrant

    cloned dev

    and up and running! quick and painless

    i 6 januari 2013 16:43
  • Satyakam Goswami sa:

    using virtual env also the dev environment is working well

    i 3 december 2012 11:54
  • Satyakam Goswami sa:

    Why the dev list is not open , i tried posing a question regading irc , i could not find the room #p2pu-dev on freenode?

    i 3 december 2012 11:53

    Dirk sa:

    Hi Satyakam

    We typically moderate the first mail that anyone sends to the email list to stop spammers from telling us that we won the lottery :) After that your messages should go through immediately



    i 4 december 2012 08:34 som svar på Satyakam Goswami
  • Bo Z sa:

    I havn't touched my dev environment for about 2 months now. I just synced the code on Monday and went through the setup steps following the document. However, I got stuck at Database creation. That is, when I ran 'make syncdb', I got the following error. Any ideas? Thank you. ( I removed some error messages in the middle to save page space. I can post them if anyone thinks it's necessary)

    Running migrations for djcelery:
     - Migrating forwards to 0002_initial.
     > djcelery:0002_initial
    Traceback (most recent call last):


      File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 81, in run_migration
      File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 57, in <lambda>
        return (lambda: direction(orm))
      File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/djcelery/migrations/", line 15, in forwards
      File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/db/", line 226, in create_table
        ', '.join([col for col in columns if col]),
      File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/db/", line 150, in execute
        cursor.execute(sql, params)
      File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/db/backends/", line 34, in execute
        return self.cursor.execute(sql, params)
    /django/db/backends/sqlite3/", line 234, in execute
        return Database.Cursor.execute(self, query, params)
    django.db.utils.DatabaseError: table "djcelery_intervalschedule" already exists
    make: *** [syncdb] Error 1

    i 20 juni 2012 21:47

    Dirk sa:

    It's a little difficult to say exactly what went wrong, but try to update your requirments:

    pip install -r requirements/prod.txt

    Then wipe your database (remove/rename the sqlite file) and try to sync again. If you still get errors, post back here so that we can get to the bottom of it.



    i 21 juni 2012 04:18 som svar på Bo Z

    Jos sa:

    Hi there,

    have you tried the FORCE_DB option as explained in the cheat sheet?

    i 21 juni 2012 04:18 som svar på Bo Z

    Bo Z sa:

    I just did. It skips syncing a bunch of apps. After that I can run the server, but as soon as I visit the website, I get a django error page saying "no such table: tracker_googleanalyticstracking". So I guess I still need syncdb to migrate fully?

    i 21 juni 2012 20:46 som svar på Jos

    Bo Z sa:

    I removed the lernanta.db file and ran 'make syncdb' again. Got the same error message.

    i 21 juni 2012 21:11 som svar på Dirk

    Dirk sa:

    I don't know exactly why that is happening? Are you working on the master branch from

    You can migrate the db for tracker only by running: "python migrate tracker"

    If this doesn't work, run 'python sql tracker' and post the output here. Then we can see wat tables should be generated. You can also inspect what is going on in the current db using "sqlite3 lernanta.db" and then running ".schema tracker_googeleanalyticstracking"

    I hope some of this helps :)

    i 22 juni 2012 06:12 som svar på Bo Z

    Bo Z sa:

    Thanks for the tip. I managed to migrate all other apps than djcelery. I will just ignore that for now since I can probably get some work done without it.

    i 23 juni 2012 15:19 som svar på Dirk
  • Jessy Kate Schingler sa:

    i used a clean-slate virtualenv with no site packages and just a dev (sqlite3) database. i had a few hiccups, the main one being around m2crypto. 

    • m2crypto hell: ubuntu doesn't compile sslv2 into the openssl package, so installing the vanilla python package for m2crypto via pip causes the error: undefined symbol: SSLv2_method

    i dont quite understand why still, but if you apt-get install python-m2crypto and then copy the system package into the virtualenv manually (as suggested here), there is no error. i guess because the system package via apt is compiled with a recognition of this missing sslv2 support? anyway, it's better than hacking the m2crypto package code yourself. is there a better solution? action i took: 

    cp -r /usr/lib/python2.7/dist-packages/M2Crypto* ~/virtualenvs/lernanta/lib/python2.7/site-packages/ 

    (note the * to copy both the .egg file and the actual package) (and of course paths may be different on your system). 

    • PIL: if you're using a virtualenv with no site packages (the default in newer versions of virtualenv, as it should be!) then you definitely will need to install PIL locally in the virtualenv (along with other packages mentioned in troubleshooting section of
    • need to create admin account credentials:
      • ./ createsuperuser
    • would be great to include some demo data to get new devs started. creating test courses is a big hassle :p. 
    i 10 juni 2012 22:03

    Dirk sa:

    Hi Jessy

    I also tried the clean-slate virtualenv and ran into the same problems! I think I also had problems with MySQL-python?

    I don't know if the --no-site-packages are the answer. I like the idea, but I read around a bit and there seems to be some consenses that certain packages are best handled by your OS' package manager. [needs reference]

    There is some test data in lernanta/apps/badges/fixtures. I had trouble loading some of it whiile running mysql.

    Even though configuring mysql requires slighly more work, I think it's better running a dev enviroment closer related to production. At some stage we will need to invest some time into setting up a vagrant environment!

    Thanks for you feedback!


    i 11 juni 2012 04:34 som svar på Jessy Kate Schingler

    Dirk sa:

    i 11 juni 2012 04:58 som svar på Dirk
  • dany javier sa:

    well the install documentation is really nice and clear. i don't have any problem, i followed the guide step by step.

    i 27 maj 2012 01:23

    Dirk sa:

    I noticed that you submitted a pull request on github! Thank you very much for your contribution!

    You can apply for the Open source contributor badge ( that applies to this challenge if you like!

    i 1 juni 2012 09:07 som svar på dany javier
  • Philipp sa:

    I've got lernanta up and running (can start the server and access the home page).

    However, when I create a course, I get the following error message. Any help appreciated.

    TypeError at /groups/create/


    __init__() got an unexpected keyword argument 'parser'
    Request Method: POST
    Request URL:
    Django Version: 1.3
    Exception Type: TypeError
    Exception Value:
    i 12 maj 2012 09:55

    Jos sa:

    Hey Philipp, seems like your DB is out of sync with your code. Have you followed the tricks in the cheat sheet to keep the DB up to date? If you haven't, I would try to recreate the DB for tests:


    FORCE_DB=True python test

    and then try running the tests:


    python test

    If that all works, then you should be good to go.

    i 12 maj 2012 13:23 som svar på Philipp

    Philipp sa:

    I'd try running the tests (with FORCE_DB=True) but get the same error for all tests:


    TypeError: __init__() got an unexpected keyword argument 'parser'
    It's been a while since I tried installing a webapplication and I might be missing something obvious. 
    i 12 maj 2012 15:52 som svar på Jos

    Dirk sa:

    I don't think you are missing something obvious? We may need a little more data.

    On the terminal, go into the virtual enviroment:

    $ workon lernanta

    and then run:

    $ pip freeze | grep html5lib

    I get "html5lib==0.95"

    If you get something else, try to do a

    $ pip install html5lib==0.95

    and let us know if that resolves the issue?

    html5lib isn't listed in lernanta/requirements/prod.txt, so that may be the issue?

    i 14 maj 2012 04:19 som svar på Philipp

    Jos sa:

    I've just updated my clone and it all works fine. I have the same version of html5lib so if it's not in the reqs files, then it 's probably being pulled in as a dependency.

    The two steps I did wre:


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


    python migrate --all --delete-ghost-migrations

    that worked for me. Also all tests run fine forcing the DB updagre. Let us know how you get on.

    i 15 maj 2012 08:45 som svar på Dirk

    Philipp sa:

    Hey - Success!

    (1) I checked the lib5html version and it was up to date.

    (2) I ran the pip install and python migrate commands. pip re-downloaded a whole bunch of stuff and then installed a few of the dependencies, so apparently it hadn't completed installing them before. The migrate command actually looked like it had failed (i'll post the output below) but after running it I was able to start the server and can create a course without getting an error now. 

    Thanks abunch for all the help!


    Running migrations for djcelery:
     - Migrating forwards to 0001_initial.
     > djcelery:0001_initial
    Traceback (most recent call last):
      File "", line 26, in <module>
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/core/management/", line 438, in execute_manager
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/core/management/", line 379, in execute
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/core/management/", line 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/core/management/", line 220, in execute
        output = self.handle(*args, **options)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/management/commands/", line 105, in handle
        ignore_ghosts = ignore_ghosts,
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 191, in migrate_app
        success = migrator.migrate_many(target, workplan, database)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 221, in migrate_many
        result = migrator.__class__.migrate_many(migrator, target, migrations, database)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 292, in migrate_many
        result = self.migrate(migration, database)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 125, in migrate
        result =
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 99, in run
        return self.run_migration(migration)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/", line 82, in run_migration
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/db/", line 184, in execute_deferred_sql
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/db/", line 150, in execute
        cursor.execute(sql, params)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/db/backends/", line 34, in execute
        return self.cursor.execute(sql, params)
      File "/home/l2p/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/db/backends/sqlite3/", line 234, in execute
        return Database.Cursor.execute(self, query, params)
    django.db.utils.DatabaseError: index djcelery_periodictask_17d2d99d already exists
    i 15 maj 2012 14:19 som svar på Jos

    Jos sa:

    Great stuff!

    both requirements files (dev and prod) should be watched for because if there is any change in them, then you will need to do the pip install step again. Have fun! :)

    i 15 maj 2012 14:39 som svar på Philipp
  • Prasanth sa:


    I have managed to get lernanta running on localhost and also created an account and signed in. I would like to make two suggestions based on the experience:


    In the documentation at

    we are asked to:

    " you can download the latest code or one of its past versions."

    I tried this with tag 1.5 but didn't work. Following Dirk's suggestion below, I tried the latest commit in repo, and it worked. 

    So perhaps the instructions should be modified?


    There is already a SECRET_KEY in, so is there a need for creating a new one?

    In any case, even with the latest commit in repo I get import error:

    $ ./ shell


    In [1]: from django.utils.crypto import get_random_string
    ImportError                               Traceback (most recent call last)
    /home/phn/code/lernanta/lernanta/<ipython-input-1-c736522aaa3d> in <module>()
    ----> 1 from django.utils.crypto import get_random_string
    ImportError: cannot import name get_random_string








    i 20 april 2012 10:54

    Jos sa:

    Hi Prasanth, have you tried running the tests as explained in the cheat sheet. I just left a comment in the previous post to this one with a similar explanation. Not sure it will work but good to give it a go.

    i 12 maj 2012 13:25 som svar på Prasanth
  • Prasanth sa:

    I followed the instructions at


    1. I downloaded the 1.5 tag of lernanta code repository.

    2. I couldn't generate SECRET_KEY:



    In [1]: from django.utils.crypto import get_random_string
    ImportError                               Traceback (most recent call last)
    /home/phn/tmp/p2pu-lernanta-7077779/lernanta/<ipython console> in <module>()
    ImportError: cannot import name get_random_string
    Since there was already a SECRET_KEY in, I went ahead and ran
    make syncdb
    There were no error messages.
    3. I ran ./ runserver. But got the following error when visiting


    ViewDoesNotExist at /

    Could not import badges.views. Error was: cannot import name send_badges
    Request Method: GET
    Request URL:
    Django Version: 1.3
    Exception Type: ViewDoesNotExist
    Exception Value:
    				Could not import badges.views. Error was: cannot import name send_badges
    Exception Location: /home/phn/lib/pyvirtualenv/lernanta/local/lib/python2.7/site-packages/django/core/ in _get_callback, line 167
    Python Executable: /home/phn/lib/pyvirtualenv/lernanta/bin/python


    Am I making any obvious mistakes?

    i 20 april 2012 07:04

    Dirk sa:

    Hi Prasanth

    Could you maybe try the latest version of Lernanta from github? I see the 1.5 tag is already 6 months old!

    Let us know if you still get errors?



    i 20 april 2012 07:11 som svar på Prasanth

    Prasanth sa:


    The latest commit in the Github repo works.

    Thanks for the quick reply.




    i 20 april 2012 10:40 som svar på Dirk
  • Dirk sa:

    Everything went perfect! Probably because of all the brave people breaking the ground before me!!

    One question: the two

    pip install

    commands took quite a while to complete ( more than 10 minutes each). Is this normal?

    i 3 april 2012 07:43

    Zuzel Vera sa:

    it takes a while for me too, both the downloads and the actual install of the dependencies.

    i 3 april 2012 09:20 som svar på Dirk
  • Corbin Tarrant sa:

    I'm up to this point in the setup doc: 

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

    but I'm getting this:

    SWIG/_m2crypto.i:31: Error: Unable to find 'openssl/opensslv.h'
    SWIG/_m2crypto.i:45: Error: Unable to find 'openssl/safestack.h'
    SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
    SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'
    error: command 'swig' failed with exit status 1
    i 5 mars 2012 02:40

    Jos sa:

    Hi Corbin, 

    which OS are you working on? if you are in ubuntu, could you check that the library libssl-dev is installed?

    apt get install libssl-dev

    should do the trick. In other linux distros the package might be called openssl-devel.


    Hope that helps!


    i 5 mars 2012 03:49 som svar på Corbin Tarrant

    Corbin Tarrant sa:

    I'm working on Ubuntu 10.04 and installing libssl-dev fixed the problem, thanks!

    i 5 mars 2012 14:11 som svar på Jos
  • David Beckley sa:

    Well, it's up and running now.


    There were some snags with the documentation, for example, a program named swig needed to be installed.


    In addition, PIL's Image module wasn't found at first, so I had to edit some files to change import Image to from PIL import Image. I had the latest version of PIL, so I'm not sure what the problem is. I posted a message to the p2pu-dev mailing list, and am waiting for a response.

    i 22 februari 2012 14:51
  • Jos sa:

    Hi all, I found a really useful series of 5 minute long screencasts to understand what virtualenv and pip do, if like me, you are new to django. The first one is here, and you can find the other 4 parts in the same channel.



    i 4 februari 2012 10:44

    Corbin Tarrant sa:

    Thank you, these videos were helpful!

    i 5 mars 2012 02:44 som svar på Jos

    Corbin Tarrant sa:

    I am a couple steps further now and trying to create the database but I am experiencing the same error a couple others (including yourself) have posted that they had below: "No module named Image"


            pip install PIL --upgrade

    just tells me that "Requirement already up-to-date"

    i 5 mars 2012 14:23 som svar på Jos

    Jos sa:

    Have you installed the "python-imaging" dependency?

    How did you create your environment? "mkvirtualenv lernanta" should allow you to use the python-imaging installed in your system. The old instructions used a --no-site-packages flag that should not be used anymore, or so I think!

    i 5 mars 2012 14:31 som svar på Corbin Tarrant

    Corbin Tarrant sa:

    My system tells me that "python-imaging is already the newest version"

    I created my dev environment as specified in this document posted above.

    i 5 mars 2012 14:49 som svar på Jos

    Jos sa:

    Apparently virtualenvwrapper changed flags in the latest version or so; could you try creating your environment with:

    mkvirtualenv lernante --system-site-packages

    That should allow access to your system PIL. Hope that works!

    i 5 mars 2012 15:01 som svar på Corbin Tarrant

    Corbin Tarrant sa:

    That worked, the database has been created!

    Thanks again!

    My dev environment is all setup and I can start the server and connect to it. The process was a little bumpy and I think it would be helpful to add to the documentation some of the common problems discussed in these comments. I also think the short 5 part video series on python and virtualenv that were posted would be very helpful for people to watch, it was for me.

    i 5 mars 2012 16:07 som svar på Jos

    Jos sa:

    Great stuff!

    Yeah, it was helpful for me too. I've been adding the steps to the doc as we were going along so I will add both the last bit (the flag) and the link to the videos. The wiki is open for editing so if you see anything missing feel free to add to it. :)



    i 5 mars 2012 16:47 som svar på Corbin Tarrant
  • Anonym sa:

    Just finished re-installing lernanta's instance so I can do some development on it!

    Some problems I encountered were...
    * I tried creating a bash script to export the virtual env variables, which I finally realised were completely losts due to the variables only being created while the script was running.
    *The Imaging bug when creating the db, apparently PIL needed a forced upgrade.
    * Having to install SWIG manually, and compile & find a missing dependency so that compiling would complete (PCRE).

    All this so I can update my Github with the lastest branch, phew.

    I'm not quite finished yet!  

    i 31 januari 2012 00:52
  • Vitor Pellegrino sa:

    I ran into a pesky bug related to Ubuntu's Open SSL and python-m2crypto. I've covered the steps i went through to solve it in this blog post.


    I had to use mkvirtualenv --system-site-packages lernanta instead of mkvirtualenv lernanta.  so my system would also look for system site packages, as Virtualenv changed its default behavior in 1.7. 

    I hope it helps other ubuntu users! 


    i 10 januari 2012 22:31
  • Jos sa:

    The documentation for Mac OSX here can be used with Lion.

    I did not install mysql or did another full install of python with homebrew (just used the default python with Lion which is 2.7.1)

    I did run into trouble with PIL (message was: ImportError: No module named Image). I fixed it by upgrading PIL from pip with: pip install PIL --upgrade

    i 26 november 2011 19:19

    Jessica Ledbetter sa:

    Great! Thank you.

    i 20 december 2011 13:35 som svar på Jos
  • Aaron V. sa:

    I'm on Mac OS X 10.6, and I get "ImportError: No module named Image" when I try to run the "make syncdb" step

    i 15 november 2011 14:40

    Jos sa:

    Hi Aaron, I had the same problem and fixed it with:

    pip install PIL --upgrade



    i 26 november 2011 18:37 som svar på Aaron V.
  • praveen sa:

    Wow! installation was a breeze. The steps in the README worked flawlessely (Ubuntu 11.04)

    i 11 oktober 2011 13:01

    Jessica Ledbetter sa:

    Great to hear!

    i 12 oktober 2011 10:26 som svar på praveen
  • arturh sa:

    I tried to install lernata on my mac without success. Some error about "mysql_config" not being there, although it was installed via MacPorts. I went the path of least resistance and got me a virtualbox instance with a minimal Ubuntu 11.04 server installation, followed instructions in README.rst (besides skipping setting up mysql, default configuration with mysql seems to work).

    i 1 september 2011 13:08