Install booktype on ubuntu 11.10
  • Hello people,

    i'm a php web dev but i can't install on my server BookType CMS.



    I have setup a LAMP werbserver with latest ubuntu 11.10 64bit
    version. I have a virtual machine with it on my windows 7 pc.



    I have done all

    Booktype prerequisites

    but the latest step


     - Unidecode (http://pypi.python.org/pypi/Unidecode)

           $ sudo pip install unidecode

    give me an error.



    Then i have tried to follow the

    Installing from the git repository

    part but at the end when i go to

    http://127.0.0.1:8000/

    i have a server error. So i have tried again from start and i have
    a new error "Template does not exists at/".

    So again i have started from begin and now i have the first server
    error which not found anything at

    http://127.0.0.1:8000/

    Can you help me to setup it??



    Also, is this cms written and php or only py?? I have to make an
    interface between it and my joomla site.



    Regards
  • 16 Comments sorted by
  • Mattia

    To get unidecode to install:

    $ sudo apt-get install python-pip

    then restart your install from there...

    $ sudo pip install unidecode

    [I'm stuck further on than that ;-) ] 
    Post edited by Daryl Moon at 2012-02-19 11:53:26
  • I get stuck on the line:

    django-admin.py syncdb --noinput

    with the error:

    settings cannot be imported because variable %s is undefined
    and
    settings cannot be imported because variable DJANGO_SETTINGS_MODULE is undefined

    Can anyone shed any light on this problem?
  • Can you try (from your booktype install folder):
     . ./booki.env


    then syncdb

    Post edited by adam at 2012-02-19 13:49:26
  • I am having the same problem. I am following the instructions or at least trying to and have the stuff could not be found. One problem was that no "easy_install" existed. Another was "pip" did not exist. Finally I got through those parts, and found that the DJANGO_SETTINGS_MODULE environment variable could not be found. After several hours of searching, I edited the bashrc files to have it set. And now it tells me:

    "ImportError: Could not import settings 'booktype.settings' (Is it on sys.path?): No module named booktype.settings"

    Of course the file can not be found, it does not exist on my system because nothing ever created it. I am stuck on the syncdb step. Please help me as well.
  • "Createbooki" script will create Booktype project for you. Among other things, it will also create file with all nedded environment variables (DJANGO_SETTINGS_MODULE, PATH, ...). File is called "booki.env" and you should load it (step 6 in instructions) after you have changed all needed settings. Directory created with "createbooki" is your Booktype project, booki.env is including it in it PYTHONPATH and etc. After you have loaded ". ./booki.env" (step 6 in instructions) you should have all paths set.
  • I have already run createbooki script and ". ./booki.env" multiple times. I still have that error. I do not know what "all needed settings" means. If you would care to explain EXACTLY what settings I need to change, I will gladly change them to make this headache go away. I just tried again to make sure, and I still have the same error on step 7. Maybe I am giving you the wrong error or not enough information, so here it is:


    dev@dev:/var/www/booktype$ django-admin syncdb --noinput
    Traceback (most recent call last):
      File "/usr/bin/django-admin", line 5, in <module>
        management.execute_from_command_line()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 429, in execute_from_command_line
        utility.execute()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 261, in fetch_command
        klass = load_command_class(app_name, subcommand)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 67, in load_command_class
        module = import_module('%s.management.commands.%s' % (app_name, name))
      File "/usr/lib/pymodules/python2.7/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/usr/lib/pymodules/python2.7/django/core/management/commands/syncdb.py", line 7, in <module>
        from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
      File "/usr/lib/pymodules/python2.7/django/core/management/sql.py", line 6, in <module>
        from django.db import models
      File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in <module>
        if not settings.DATABASES:
      File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276, in __getattr__
        self._setup()
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 44, in _setup
        self._wrapped = Settings(settings_module)
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 89, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/lib/pymodules/python2.7/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/var/www/booktype/settings.py", line 172, in <module>
        init_logging()
      File "/var/www/booktype/settings.py", line 163, in init_logging
        ch = logging.handlers.RotatingFileHandler('%s/logs/booki.log' % BOOKI_ROOT, maxBytes=100000, backupCount=5)
      File "/usr/lib/python2.7/logging/handlers.py", line 118, in __init__
        BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
      File "/usr/lib/python2.7/logging/handlers.py", line 65, in __init__
        logging.FileHandler.__init__(self, filename, mode, encoding, delay)
      File "/usr/lib/python2.7/logging/__init__.py", line 893, in __init__
        StreamHandler.__init__(self, self._open())
      File "/usr/lib/python2.7/logging/__init__.py", line 912, in _open
        stream = open(self.baseFilename, self.mode)
    IOError: [Errno 13] Permission denied: '/var/www/booktype/logs/booki.log'
    dev@dev:/var/www/booktype$ sudo django-admin syncdb --noinput
    Traceback (most recent call last):
      File "/usr/bin/django-admin", line 5, in <module>
        management.execute_from_command_line()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 429, in execute_from_command_line
        utility.execute()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 261, in fetch_command
        klass = load_command_class(app_name, subcommand)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 67, in load_command_class
        module = import_module('%s.management.commands.%s' % (app_name, name))
      File "/usr/lib/pymodules/python2.7/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/usr/lib/pymodules/python2.7/django/core/management/commands/syncdb.py", line 7, in <module>
        from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
      File "/usr/lib/pymodules/python2.7/django/core/management/sql.py", line 6, in <module>
        from django.db import models
      File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in <module>
        if not settings.DATABASES:
      File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276, in __getattr__
        self._setup()
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 44, in _setup
        self._wrapped = Settings(settings_module)
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 91, in __init__
        raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
    ImportError: Could not import settings 'booktype.settings' (Is it on sys.path?): No module named booktype.settings

  • Okay, I just deleted everything, and tried fresh install. I get the following error following your guidelines:



    dev@dev:/usr/www/mybooktype$ sudo vi settings.py
    dev@dev:/usr/www/mybooktype$ . ./booki.env
    dev@dev:/usr/www/mybooktype$ sudo django-admin syncdb --noinput
    Traceback (most recent call last):
      File "/usr/bin/django-admin", line 5, in <module>
        management.execute_from_command_line()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 429, in execute_from_command_line
        utility.execute()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 261, in fetch_command
        klass = load_command_class(app_name, subcommand)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 67, in load_command_class
        module = import_module('%s.management.commands.%s' % (app_name, name))
      File "/usr/lib/pymodules/python2.7/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/usr/lib/pymodules/python2.7/django/core/management/commands/syncdb.py", line 7, in <module>
        from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
      File "/usr/lib/pymodules/python2.7/django/core/management/sql.py", line 6, in <module>
        from django.db import models
      File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in <module>
        if not settings.DATABASES:
      File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276, in __getattr__
        self._setup()
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 44, in _setup
        self._wrapped = Settings(settings_module)
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 91, in __init__
        raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
    ImportError: Could not import settings 'booktype.settings' (Is it on sys.path?): No module named booktype.settings
    dev@dev:/usr/www/mybooktype$ cd /usr/lib/pymodules/python2.7/django/conf
    dev@dev:/usr/lib/pymodules/python2.7/django/conf$ sudo vi __init__.py
    dev@dev:/usr/lib/pymodules/python2.7/django/conf$ cd /usr/www/mybooktype/dev@dev:/usr/www/mybooktype$ sudo django-admin syncdb --noinput
    Traceback (most recent call last):
      File "/usr/bin/django-admin", line 5, in <module>
        management.execute_from_command_line()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 429, in execute_from_command_line
        utility.execute()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 261, in fetch_command
        klass = load_command_class(app_name, subcommand)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 67, in load_command_class
        module = import_module('%s.management.commands.%s' % (app_name, name))
      File "/usr/lib/pymodules/python2.7/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/usr/lib/pymodules/python2.7/django/core/management/commands/syncdb.py", line 7, in <module>
        from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
      File "/usr/lib/pymodules/python2.7/django/core/management/sql.py", line 6, in <module>
        from django.db import models
      File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in <module>
        if not settings.DATABASES:
      File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276, in __getattr__
        self._setup()
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 42, in _setup
        raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
    ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

  • Reply to @Fred:
    Hi Fred... ok.. So, you have used createbooki to install Booktype project into /usr/www/mybooktype? Check your booki.env file. You must have:
      export DJANGO_SETTINGS_MODULE=mybooktype.settings
    and
      export PYTHONPATH=$PYTHONPATH:/usr/www/
    defined. Looking at this errors you can see that Django thinks settings module is booktype.settings. Did you rename directory or something? Check your booki.env file, correct values if they are wrong, load booki.env again and try again.
  • I am thinking the problem might stem from not being able to run ". ./booki.env" as a superuser. Either that, or because the settings file itself is not on my system. Regardless, I restarted my system, and now I am back to the DJANGO_SETTINGS_MODULE environment variable being not found. When I try to run django-admin without the sudo in front, it says permission denied. I think that may cause the error, if not I am clueless and frustrated. See below:


    dev@dev:/usr/www/mybooktype$ . ./booki.env
    dev@dev:/usr/www/mybooktype$ sudo django-admin syncdb --noinput
    Traceback (most recent call last):
      File "/usr/bin/django-admin", line 5, in <module>
        management.execute_from_command_line()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 429, in execute_from_command_line
        utility.execute()
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 261, in fetch_command
        klass = load_command_class(app_name, subcommand)
      File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 67, in load_command_class
        module = import_module('%s.management.commands.%s' % (app_name, name))
      File "/usr/lib/pymodules/python2.7/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/usr/lib/pymodules/python2.7/django/core/management/commands/syncdb.py", line 7, in <module>
        from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
      File "/usr/lib/pymodules/python2.7/django/core/management/sql.py", line 6, in <module>
        from django.db import models
      File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in <module>
        if not settings.DATABASES:
      File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276, in __getattr__
        self._setup()
      File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 42, in _setup
        raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
    ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
    dev@dev:/usr/www/mybooktype$
  • I did check the booki.env file and everything looks the way you said it should look.
  • Reply to @Fred:
    You can always manualy setup variables to see what will happen. Just copy whatever you have manualy in booki.env file. For instance:

    $ export DJANGO_SETTINGS_MODULE=mybooktype.settings
    ...etc...

    Now you variables should be set and you can try to do django-admin commands.
  • Okay, I got past that part and now i am stuck with step 9.

    dev@dev:/usr/www/mybooktype$ django-admin migrate
    Unknown command: 'migrate'
    Type 'django-admin help' for usage.
  • I'm having the same problem as @Fred and @Daryl:

    ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

    I'm using a Postgresql database. The PATHs in booki.env are:

    export DJANGO_SETTINGS_MODULE=mybooktype.settings (Is this the settings.py file in /mybooktype directory?)

    PYTHONPATH=$PYTHONPATH:/var/www/:/var/www/mybooktype/lib/:/home/paul/Downloads/sourcefabric-Booktype-1188220/lib

    PATH=$PATH:/usr/lib/pymodules/python2.7/django/bin

    The instance is installed in /var/www/mybooktype .

    I've made no other settings changes other than name and email address in settings.py .
  • OK. I solved the above problem by 'su root' and running $. ./booki.env (this would not run via 'sudo'), and then 'django-admin syncdb --noinput'.

  • Thanks for sharing this solution. Very helpful to me.