Tim Gaudette sa:
updated virtual box to 4.2 because it has been a while since I used it
and up and running! quick and painless
This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.
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.
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?
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.
Traceback (most recent call last):
File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/migrators.py", line 81, in run_migration
File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/djcelery/migrations/0002_initial.py", line 15, in forwards
File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/south/db/generic.py", 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/generic.py", line 150, in execute
File "/home/vampb/.virtualenvs/lernanta/local/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
/django/db/backends/sqlite3/base.py", line 234, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: table "djcelery_intervalschedule" already exists
make: *** [syncdb] Error 1
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 don't know exactly why that is happening? Are you working on the master branch from github.com/p2pu/lernanta?
You can migrate the db for tracker only by running: "python manage.py migrate tracker"
If this doesn't work, run 'python manage.py 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 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.so: 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).
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 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 (https://p2pu.org/en/badges/p2pu-open-source-developer/) that applies to this challenge if you like!
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: POSTRequest URL: http://127.0.0.1:8000/en/groups/create/Django Version: 1.3Exception Type: TypeErrorException Value:
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 manage.py test
and then try running the tests:
python manage.py test
If that all works, then you should be good to go.
I'd try running the tests (with FORCE_DB=True) but get the same error for all tests:
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'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 manage.py 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.
Hey - Success!
(1) I checked the lib5html version and it was up to date.
(2) I ran the pip install and python manage.py 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!
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:
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 settings.py, so is there a need for creating a new one?
In any case, even with the latest commit in repo I get import error:
$ ./manage.py shell
I followed the instructions at https://github.com/p2pu/lernanta/wiki/Lernanta%27s-Setup-Install.
1. I downloaded the 1.5 tag of lernanta code repository.
2. I couldn't generate SECRET_KEY:
Could not import badges.views. Error was: cannot import name send_badges
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/urlresolvers.py in _get_callback, line 167|
Am I making any obvious mistakes?
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
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!
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 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"
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!
That worked, the database has been created!
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.
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. :)
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 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!
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 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).