Initialize Database
Forum » WikiPBX / Technical Support » Initialize Database
Started by: Solo9300Solo9300
On: 1261236724|%e %b %Y, %H:%M %Z|agohover
Number of posts: 32
rss icon RSS: New posts
Initialize Database
Solo9300Solo9300 1261236724|%e %b %Y, %H:%M %Z|agohover

Hello All,
i am trying to get wikipb to work on my box using this http://wikipbx.subwiki.com/installation-manual-0-8 manual. However when i reach Initialize Database i get this

user@server:~$ cd /usr/src/wikipbx/wikipbx
user@server:/usr/src/wikipbx/wikipbx$ sudo python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 39, in <module>
    execute_manager(settings)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 221, in execute
    self.validate()
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "/usr/lib/pymodules/python2.6/django/core/management/validation.py", line 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/usr/lib/pymodules/python2.6/django/db/models/loading.py", line 131, in get_app_errors
    self._populate()
  File "/usr/lib/pymodules/python2.6/django/db/models/loading.py", line 58, in _populate
    self.load_app(app_name, True)
  File "/usr/lib/pymodules/python2.6/django/db/models/loading.py", line 74, in load_app
    models = import_module('.models', app_name)
  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/src/wikipbx/wikipbx/../wikipbx/wikipbxweb/models.py", line 98, in <module>
    class SipProfile(models.Model):
  File "/usr/src/wikipbx/wikipbx/../wikipbx/wikipbxweb/models.py", line 106, in SipProfile
    name = models.CharField(maxlength=50, null=False)
TypeError: __init__() got an unexpected keyword argument 'maxlength'

Any help would be much appreciated.

Reply  |  Options
Unfold Initialize Database by Solo9300Solo9300, 1261236724|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261242207|%e %b %Y, %H:%M %Z|agohover

You're running a version of django that is too new. Please install a supported version as described in the manual.

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261242207|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261263066|%e %b %Y, %H:%M %Z|agohover

We are working on a version that will work with more recent versions of Django, but in the meantime you have to use an older one (as mentioned). Sorry about the hassle.

Also a little off topic, but the forum has a bit dead and we are discussing other options to engage the user community more. Would you prefer a mailing list or a better forum, or does the forum work for you?

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261263066|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261366690|%e %b %Y, %H:%M %Z|agohover

Well, i think the forum just fine.

Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261366690|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261366293|%e %b %Y, %H:%M %Z|agohover

Hello again,

well I format my box and install a fresh copy of ubuntu 9.10 server and did every thing in the manual . However when i reach Initialize Database i get this

user@server:/usr/src/wikipbx/wikipbx$ sudo python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 30, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management

Any help would be much appreciated.

Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261366293|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261388433|%e %b %Y, %H:%M %Z|agohover

I think maybe Django is not being found by your pyton VM. I looked and the instructions were a little confusing:

Get Django

Django provides the O/R mapping layer to the database, and runs as a WSGI in the webserver and handles all the requests.

Django has only been tested up to revision 5024, (in Django source tree). Attempting to run with later versions of Django won't work.

 cd /usr/src
 svn co --revision 5024 http://code.djangoproject.com/svn/django/trunk/ django
 ln -s /usr/src/django/django /usr/lib/python2.x/site-packages

See djangoproject.com for more complete instructions.

If you followed them literally you'd have a broken symlink.

Try this

  • Type "python" at command line
  • What version of python is it?
  • Type "import django" — do you get an error?
  • If its 2.5, try codels /usr/lib/python2.x/site-packages/code
  • Do you see a symlink to django subdirectory under the directory where you downloaded django to.
Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261388433|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261390668|%e %b %Y, %H:%M %Z|agohover

Traun meant this:

If its 2.5, try ls /usr/lib/python2.5/site-packages

You're supposed to replace 2.X with the actual python version used here and when running "ln -s …" command in the shell to make a symlink. Your error means that django isn't installed or installed where python can't find it.

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261390668|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261393053|%e %b %Y, %H:%M %Z|agohover

You're supposed to replace 2.X with the actual python version

i did replace it with 2.6

Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261393053|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261392972|%e %b %Y, %H:%M %Z|agohover
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

and yes there is symlink to django subdirectory

Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261392972|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261396459|%e %b %Y, %H:%M %Z|agohover

And what about this:

Type "import django" — do you get an error?

If it works then run in python console:

 print(django.__file__)

It should output a path name like /usr/lib/python2.6/site-packages/django.pyc . This in necessary to make sure that you don't have some other library/module/script named django that gets imported instead of the django framework.

When you run these commands you should be using the same environment as you're going to run in production, i.e. run it with sudo as it may have effect on python environment.

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261396459|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261398456|%e %b %Y, %H:%M %Z|agohover

i got this

user@server:~$ import django
The program 'import' can be found in the following packages:
 * imagemagick
 * graphicsmagick-imagemagick-compat
Try: sudo apt-get install <selected package>
import: command not found
user@serve1:~$ sudo python  import django
python: can't open file 'import': [Errno 2] No such file or directory

user@server:~$ python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named django
>>>
Last edited on 1261398559|%e %b %Y, %H:%M %Z|agohover By Solo9300 + Show more
Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261398456|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261403423|%e %b %Y, %H:%M %Z|agohover

"import django" is a python command, it should be run in python's command line not system shell. As it fails, it means that django is not installed in the python version you run.

To help figuring out what's wrong with your setup, enter this command in the shell:

ls -lh /usr/lib/python2.6/site-packages/django

It should print the path where your django symlink is pointing. Next command is almost the same, except the trailing slash. It prints the contents of directory where the symlink points.

ls -lh /usr/lib/python2.6/site-packages/django/

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261403423|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261417099|%e %b %Y, %H:%M %Z|agohover

So it looks like python can't find the django modules/classes. This should be really easy to fix..

What is the output from this shell cmd?

$ ls -al /usr/lib/python2.6/site-packages | grep -i django

And this one?

$ ls -al /usr/lib/python2.6/site-packages/django

Which directory did you install django in? (eg, /usr/src/django, /opt/django, /home/foo/Django_5024)

My guess is that your symlink points to the django top level directory (eg, /usr/src/django) rather than the subdirectory where the django python modules are (eg, /usr/src/django/django)

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261417099|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261427300|%e %b %Y, %H:%M %Z|agohover

Oops didn't look at Stas' post to carefully before posting. I guess you'll want to use a trailing slash here

$ ls -al /usr/lib/python2.6/site-packages/django
Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261427300|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261439823|%e %b %Y, %H:%M %Z|agohover

well,
in "/usr/lib/python2.6" directory it show "site-packages" as symlink. therefore i delete the symlink and create the "site-packages" subdirectory under "/usr/lib/python2.6" and i run this command

ln -s /usr/src/django/django /usr/lib/python2.6/site-packages

and this the output i got

ls -lh /usr/lib/python2.6/site-packages/django

lrwxrwxrwx 1 root root 22 2009-12-21 18:20 /usr/lib/python2.6/site-packages/django -> /usr/src/django/django
ls -lh /usr/lib/python2.6/site-packages/django/

total 72K
drwxr-sr-x  4 root src 4.0K 2009-12-20 21:09 bin
drwxr-sr-x  7 root src 4.0K 2009-12-20 21:09 conf
drwxr-sr-x 20 root src 4.0K 2009-12-20 21:09 contrib
drwxr-sr-x  7 root src 4.0K 2009-12-20 21:09 core
drwxr-sr-x  5 root src 4.0K 2009-12-20 21:08 db
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:09 dispatch
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:09 forms
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:08 http
-rw-r--r--  1 root src   25 2009-12-20 21:09 __init__.py
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:09 middleware
drwxr-sr-x  4 root src 4.0K 2009-12-20 21:09 newforms
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:08 oldforms
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:09 shortcuts
drwxr-sr-x  4 root src 4.0K 2009-12-20 21:09 template
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:09 templatetags
drwxr-sr-x  3 root src 4.0K 2009-12-20 21:08 test
drwxr-sr-x  5 root src 4.0K 2009-12-20 21:09 utils
drwxr-sr-x  5 root src 4.0K 2009-12-20 21:09 views
ls -al /usr/lib/python2.6/site-packages | grep -i django

lrwxrwxrwx  1 root root    22 2009-12-21 18:20 django -> /usr/src/django/django
ls -al /usr/lib/python2.6/site-packages/django

lrwxrwxrwx 1 root root 22 2009-12-21 18:20 /usr/lib/python2.6/site-packages/django -> /usr/src/django/django
Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261439823|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261446144|%e %b %Y, %H:%M %Z|agohover

Do you remember what site-packages was symlinked to? That seems odd .. I worry that some crucial python libs somehow got lost along the way (if you accidentally deleted the site-packages directory)

So does it work now if you run the python shell and type "import django"?

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261446144|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261479418|%e %b %Y, %H:%M %Z|agohover

Well,
I am glad you guys didn't give up on me :) i really appreciated all the help.

the site-packages has only one symlink "django" which linked to /usr/src/django/django. so i thought if i delete it i wouldn't lose anything.

So does it work now if you run the python shell and type "import django"?

No i get this

Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named django
Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261479418|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261480952|%e %b %Y, %H:%M %Z|agohover

What do you get if you run:

sudo python -c 'import sys; print sys.path'
Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261480952|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261492140|%e %b %Y, %H:%M %Z|agohover
sudo python -c 'import sys; print sys.path'
['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
Last edited on 1261492161|%e %b %Y, %H:%M %Z|agohover By Solo9300 + Show more
Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261492140|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261500890|%e %b %Y, %H:%M %Z|agohover

Ok, now it's pretty clear. Looks like you're using a newer ubuntu or other debian-based distro where they've renamed site-packages to dist-packages. Don't ask me why would they want to do something that breaks most existing python third-party modules - it looks like idiotism to me.

So you can do one of the following:

1. Create the symlink in /usr/lib/python2.6/dist-packages directory instead of site-packages.

2. Add site-packages to python path by setting it:

sudo PYTHONPATH="/usr/lib/python2.6/site-packages:$PYTHONPATH" manage.py syncdb

3. Don't install django, add it's root directory to pythonpath instead:

sudo PYTHONPATH="/usr/src/django:$PYTHONPATH" manage.py syncdb

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261500890|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261507576|%e %b %Y, %H:%M %Z|agohover

after i Create the symlink everything lock ok but when i navigate to http://wikipbx.yourserver.net i got this

ViewDoesNotExist at /
Could not import wikipbx.wikipbxweb.views. Error was: No module named ESL

Request Method:    GET
Request URL:    http://wikipbx.aldimna.com/
Exception Type:    ViewDoesNotExist
Exception Value:    Could not import wikipbx.wikipbxweb.views. Error was: No module named ESL
Exception Location:    /usr/src/django/django/core/urlresolvers.py in _get_callback, line 128
tail -f /var/log/apache2/error.log /var/log/apache2/wikipbx.aldimna.com-error.log
==> /var/log/apache2/error.log <==
[Tue Dec 22 13:34:27 2009] [error] /usr/src/django/django/middleware/common.py:4: DeprecationWarning: the md5 module is deprecated; use hashlib instead
[Tue Dec 22 13:34:27 2009] [error]   import md5
[Tue Dec 22 13:34:28 2009] [error] /usr/src/django/django/db/models/fields/related.py:15: DeprecationWarning: the sets module is deprecated
[Tue Dec 22 13:34:28 2009] [error]   from sets import Set as set
[Tue Dec 22 13:34:33 2009] [error] /usr/src/django/django/middleware/common.py:4: DeprecationWarning: the md5 module is deprecated; use hashlib instead
[Tue Dec 22 13:34:33 2009] [error]   import md5
[Tue Dec 22 13:34:34 2009] [error] /usr/src/django/django/db/models/fields/related.py:15: DeprecationWarning: the sets module is deprecated
[Tue Dec 22 13:34:34 2009] [error]   from sets import Set as set
[Tue Dec 22 13:40:39 2009] [error] [client 192.0.1.1] File does not exist: /var/www/favicon.ico
[Tue Dec 22 13:40:42 2009] [error] [client 192.0.1.1] File does not exist: /var/www/favicon.ico

==> /var/log/apache2/wikipbx.aldimna.com-error.log <==
Last edited on 1261507647|%e %b %Y, %H:%M %Z|agohover By Solo9300 + Show more
Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261507576|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261509947|%e %b %Y, %H:%M %Z|agohover

See http://wikipbx.subwiki.com/troubleshooting-0-8#toc2

This means its not finding the ESL module on the python path from within the wsgi context.

Either:

* You forgot to build the ESL module for python
* You forgot to set the WSGIPythonPath wsgi variable in the apache config, or had a typo
* You correctly set it and for whatever reason its being ignored

The workaround is to modify the /usr/src/wikipbx/wikipbx.wsgi file to manually add the ESL directory. Please post on the forum if you need help with that.

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261509947|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261510475|%e %b %Y, %H:%M %Z|agohover
build the ESL module for python

Go to libs/esl directory under freeswitch source tree
Edit python/Makefile to use the version of python you prefer to use
Run make pymod

i did that

Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261510475|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261511727|%e %b %Y, %H:%M %Z|agohover

Do you have _ESL.so and ESL.py from libs/esl directory in python's dist-packages? I guess they're installed to site-packages instead.

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261511727|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261512022|%e %b %Y, %H:%M %Z|agohover

no should i copy them there

Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261512022|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261513609|%e %b %Y, %H:%M %Z|agohover

What is your current WSGIPythonPath set to?

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261513609|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261514097|%e %b %Y, %H:%M %Z|agohover

I updated http://wikipbx.subwiki.com/configure-wikipbx-mod-wsgi .. please take a look again

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261514097|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261513378|%e %b %Y, %H:%M %Z|agohover

Just checked my system and _ESL.so and ESL.py are not deployed to /usr/lib/python2.5/site-packages ..

locate ESL.py

results in ..

/usr/src/freeswitch_15699/libs/esl/python/ESL.py

which corresponds to my apache configuration WSGIPythonPath:

WSGIPythonPath /usr/src/freeswitch_13501/scripts/socket:/usr/src/wikipbx:/usr/src/django_5024:/usr/src/freeswitch_13501/libs/esl/python
Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261513378|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261519339|%e %b %Y, %H:%M %Z|agohover

I do it in a different way. I have a symlink to the active freeswitch version in /usr/src/freeswitch pointing to the active FS version and symlinks to the libs in /usr/src/freeswitch/libs/esl/… in python's site-packages dir. This way I can quickly upgrade to a new freeswitch version without modifying WSGI path. However, I'm starting to consider zero install approach to be much cleaner, so I think we should cosider using virtualenv.

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261519339|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
Solo9300Solo9300 1261515147|%e %b %Y, %H:%M %Z|agohover

well after i copy _ESL.so and ESL.py to /usr/lib/python2.5/site-packages everything work grate. i really appreciated all the help.

like i mention before i have ubuntu 9.10 server on my box and i don't know if this going to help you guys but i will format the box and install a fresh copy of ubuntu 9.10 server. And i can make a shell script to do all the steps.

coming from Microsoft environment where everything you need to do is one click, However, i did install FusionPBX and FreePBX-v3 they are much Easier put they all in php (php=bad).

anyway thanks alot for all the help and if you think the shell script would help let me know.

Last edited on 1261518245|%e %b %Y, %H:%M %Z|agohover By Solo9300 + Show more
Reply  |  Options
Unfold Re: Initialize Database by Solo9300Solo9300, 1261515147|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
tleydentleyden 1261516458|%e %b %Y, %H:%M %Z|agohover

Any scripts to simplify installation would be highly appreciated and will go into the svn repository for other users to use. We know currently wikipbx is very difficult and time consuming to install .. so if you made it all the way through consider yourself part of the elite ;)

Reply  |  Options
Unfold Re: Initialize Database by tleydentleyden, 1261516458|%e %b %Y, %H:%M %Z|agohover
Re: Initialize Database
stas_shtinstas_shtin 1261517274|%e %b %Y, %H:%M %Z|agohover

It definitely took more time than it should in your case, although it's caused by debian maintainers' weird decision in first place. It's possible to drastically simplify installation of wikipbx by using other software for configuring python dependencies, but it's not in our short time plans yet.

And definitely do stay away from PHP for anything that is more complicated than a Personal Home Page :-)

Reply  |  Options
Unfold Re: Initialize Database by stas_shtinstas_shtin, 1261517274|%e %b %Y, %H:%M %Z|agohover
New Post
page_revision: 0, last_edited: 1226259295|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License