failing to setup local instance...config issue... not sure where to start...
  • A quick overview of what I did and what is not working:

    I followed these instructions:

    Using ubuntu 14.04 LTS (I think the desktop version, but I hope that would not matter.)


    http://sourcefabric.booktype.pro/booktype-20-for-authors-and-publishers/setting-up-the-database/
    http://sourcefabric.booktype.pro/booktype-20-for-authors-and-publishers/installation-on-gnulinux/


    Everything appears to be in place well enough to run:
    django-admin.py runserver 0.0.0.0:8005

    However, the browser/app does not do what it should.

    The error I am getting is this:

    "
    Request Method:GET
    Request URL:http://black123-virt1:8005/
    Django Version:1.5
    Exception Type:TypeError
    Exception Value:

    relative imports require the 'package' argument

    Exception Location:/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py
    in import_module, line 28
    Python Executable:/usr/bin/python
    Python Version:2.7.6
    Python Path:

    ['/usr/local/src/booktype/lib/',
     Path('/var/www/booktype/instance1/lib'),
     Path('/var/www/booktype/instance1'),
     '/usr/local/bin',
     '/home/black123/src/ebooklib',
     '/var/www/booktype/instance1/instance1_site/urls',
     '/var/www/booktype/instance1',
     '/var/www/booktype/instance1/lib',
     '/usr/local/src/booktype/lib',
     '/usr/lib/python2.7',
     '/usr/lib/python2.7/plat-x86_64-linux-gnu',
     '/usr/lib/python2.7/lib-tk',
     '/usr/lib/python2.7/lib-old',
     '/usr/lib/python2.7/lib-dynload',
     '/usr/local/lib/python2.7/dist-packages',
     '/usr/lib/python2.7/dist-packages',
     '/usr/lib/python2.7/dist-packages/PILcompat',
     '/usr/lib/python2.7/dist-packages/gtk-2.0',
     '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']

    Server time:Sun, 14 Sep 2014 16:28:29 -0400
    "

    I think the issue circles around what I have set (or not set
    correctly) in either:
      /var/www/booktype/instance1/instance1_site/settings/base.py
      /var/www/booktype/instance1/instance1_site/settings/dev.py

    But I am unclear as to how to fix it.

    Any ideas what I am doing wrong?
    Is there any additional information I can give you to help you help me? :)

    Thanks in advance.
  • 13 Comments sorted by
  • Vote Up0Vote Down Daniel JamesDaniel James
    Posts: 844Member, Sourcefabric Team
    Hi Carey, are you using a virtualenv or did you install the Python libraries listed in the requirements files system-wide? Cheers! Daniel
  • I followed the steps here: http://sourcefabric.booktype.pro/booktype-20-for-authors-and-publishers/installation-on-gnulinux/

    The host is a virtual host. However, I doubt that has anything to do with your question.
    I am not a python "guy". I do not speak that programming language. So lots of this setup/inner workings are very ... odd ... to me. So I can not describe how it was installed other than by the commands that I ran.

    For instance... Why is there not a command line shell script to do the dozen checks for packages, download what is needed and prompt for config values and rewrite the needed config files? Maybe my expectations are to high, but if there is a web page list of stuff to go run for platform "X", then that could also be a shell script for that platform. (And remove lots of pain/errors from the setup of the system.)


    If you can tell me what to look at to answer your question then I will check the host and let you know. I do know my way around Linux. (And I do write code in multiple languages.) So give me a clue as to how to know that and I will get back to you.
  • Vote Up0Vote Down Daniel JamesDaniel James
    Posts: 844Member, Sourcefabric Team
    Hi Carey, for an automated install that prompts for config values, you would be better to use the Debian/Ubuntu packages that are in development. If you already have your database set up, please try the pre-release snapshot from http://apt.sourcefabric.org/snapshots/ which is based on today's git 2.0 branch.

    To install with automatic dependency resolution on your desktop machine, you can install the package gdebi-core and then use:

    sudo gdebi booktype_2.0.0~20141013-1_all.deb

    Let me know how you get on!

    Daniel
  • Hi Daniel,

    I have tried to set this up using the deb file

    How do you install for a local internal site, not on the internet or DNS

    William
  • Hi

    I tried to install booktype 2.0 in an Ubuntu 14.04

    I installed postgresql and config.

    After I did sudo gdebi booktype_2.0.0~20151019-1_all.deb

    And I have a problem : after syncdb it stops with this

    "Unknown command: 'migrate'
    Type 'manage.py help' for usage.
    dpkg: error processing package booktype (--install):"

    Has someone an idea ?

    Ph
  • Hi

    I tried a lot to install booktype_2.0.0~20151019-1_all.deb and booktype_2.0.0~20151020-1_all.deb after postgresql installation. And allways this error at the same time.

    To give more details, here the last words before the error

    Creating table messaging_endpointconfig
    Creating table messaging_following
    Installing custom SQL ...
    Installing indexes ...
    Installed 0 object(s) from 0 fixture(s)
    Unknown command: 'migrate'
    Type 'manage.py help' for usage.
    dpkg: error processing package booktype (--install):
    le sous-processus script post-installation installé a retourné une erreur de sortie d'état 1
    Des erreurs ont été rencontrées pendant l'exécution :
    booktype


    Thanks

    Ph
  • I succeeded to install booktype 2. But it's ugly (uncomment 'django.contrib.staticfiles.finders.DefaultStorageFinder' in base.py)

    But I can't export any book I created.

    There is two ways in the doc for prod.py :

    MPDF_SCRIPT = '{}/booktype2mpdf.php'.format(BOOKTYPE_ROOT)
    or
    MPDF_SCRIPT = '/usr/local/src/booktype/scripts/mpdf.php'

    But they didn't work.

    If someone...

    Bonne journée
  • ph all

    Could you please write the exact steps you took to be able to get this working.  I have tried various methods (on Ubuntu 14.04) and always end up with the "Unknown command: 'migrate'" problem.

    I tried installing manual method, and automatic install, also tried installing *.deb packages, but nothing works

    Also when I try to do the manual ./manage.py syncdb --noinput I always get the "ImportError: no module named unipath".

    It's frustrating.
  • Hi

    I tried manual method but I never could end it. I dislike python because I never understand why it works or not : once it's good, another time it fails because of *.env, path, superpath, hyperpath, and other conf things...


    After gdebi installed, gdebi booktyp....

    (I had a problem with compressor, I deleted the academic theme).

    And it works.

    I fixed supervisor (only 2 workers) like in the manual. And I have a pb with publish (another post).

    Here I am.
  • Hi

    I fixed with recent changes in the github. And allways without publishing. But new errors :


    Received task: booktype.apps.edit.tasks.publish_book[78967caa-418f-41de-a6dc-0f602e8da415]
    [2015-10-30 12:41:36,671: ERROR/Worker-1] Could not load /_convert/.
    Traceback (most recent call last):
    File "/var/lib/booktype/lib/booktype/utils/download.py", line 26, in fetch_url
    req = requests.post(url, headers=headers, data=json.dumps(data))
    File "/usr/lib/python2.7/dist-packages/requests/api.py", line 88, in post
    return request('post', url, data=data, **kwargs)
    File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
    File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 421, in request
    prep = self.prepare_request(req)
    File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 359, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
    File "/usr/lib/python2.7/dist-packages/requests/models.py", line 287, in prepare
    self.prepare_url(url, params)
    File "/usr/lib/python2.7/dist-packages/requests/models.py", line 338, in prepare_url
    "Perhaps you meant http://{0}?".format(url))
    MissingSchema: Invalid URL u'/_convert/': No schema supplied. Perhaps you meant http:///_convert/?
    [2015-10-30 12:41:36,716: ERROR/MainProcess] Task booktype.apps.edit.tasks.publish_book[78967caa-418f-41de-a6dc-0f602e8da415] raised unexpected: UnboundLocalError("local variable 'req' referenced before assignment",)
    Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
    File "/var/lib/booktype/lib/booktype/apps/edit/tasks.py", line 99, in publish_book

    File "/var/lib/booktype/lib/booktype/utils/download.py", line 34, in fetch_url
    if req.status_code != 200:
    UnboundLocalError: local variable 'req' referenced before assignment



    If someone understand why this /_convert/ pb and this new last line other pb...

    Thanks to all who read my posts

    Ph
  • Hi! 

    At this point I would recommend manual install and to use Booktype from the github. This page has instructions how to install system dependencies and required libraries.

    Let's say you want to host it using Apache, PostgreSQL, ... Also, be aware I am typing this from my head, I did not double check anything. One needs to separately create Postgres database and configure Apache and Supervisor. Also, some steps (no need for --noinput and seperate createsuperuser step) are a bit changed, but everything will be fine if you still use them.

    # become root for the first step

    $ sudo su

    # create needed directory as root and make www-data owner

    $ mkdir /var/www/mysite/
    $ chown www-data:www-data /var/www/mysite/

    # this will not work on latest version of ubuntu, but info page has instructions how to fix it
    # further steps should be done as www-data user and not root

    $ su - www-data

    # create python virtual environment

    $ cd /var/www/mysite/
    $ virtualenv --distribute venv

    # activate it

    $ source venv/bin/active

    # clone booktype

    # install python requirements
    # this will fail if you do not have required system libraries
    # instead of prod, one can also use "dev" profile. it is more verbose 
    # and will report more errors

    $ pip install -r Booktype/requirements/prod.txt

    # create booktype project

    $ ./Booktype/scripts/createbooktype -p prod -d postgresql bksite
    $ cd bksite

    # initialise project

    $ ./manage.py syncdb
    $ ./manage.py migrate
    $ ./manage.py update_permissions
    $ ./manage.py update_default_roles

    # collect static files

    $ ./manage.py collectstatic

    # compress if you have used prod profile
    $ ./manage.py compress

    That's in. In /var/www/mysite/bksite/conf/  directory you will find wsgi.apache (config file for apache) and supervisor.conf (config file for supervisor). That documentation page covers it.

    Configuration files will be
    /var/www/mysite/bksite/bksite_site/settings/base.py
    and then depending of the used profile
    /var/www/mysite/bksite/bksite_site/settings/dev.py
    or
    /var/www/mysite/bksite/bksite_site/settings/prod.py

    base.py has:








    EXPORT_ALLOWED_HOSTS = ['127.0.0.1']

    This is very important. Publishing engine and Booktype (front end + editor) do not need to be on the same server. To allow access to books you need to define from which IP addresses they could be fetched. Just add this:

    EXPORT_ALLOWED_HOSTS = ['127.0.0.1', '*']

    and it will work. After that you can edit dev.py or prod.py file. If you have installed this on the server who is accessible as bk.myserver.com you should have this









    THIS_BOOKTYPE_SERVER = 'bk.myserver.com'









    BOOKTYPE_URL = 'http://{}'.format(THIS_BOOKTYPE_SERVER)









    CONVERT_URL = BOOKTYPE_URL

    This means, that it will try to connect to http://bk.myserver.com/_convert/ to access the publishing engine. One common thing where publishing will fail is if EXPORT_ALLOWED_HOSTS is not properly defined and it Tidy html external command line application is not installed.

    After this you have MPDF to configure. You need to install php-cli and php-gd debian package for this. Go to www.mpdf1.com and download MPDF60. Let's say you did and you downloaded and unzipped it in /var/www/mysite/mpdf60/ directory. In that case you should have this.

    MPDF_DIR = '/var/www/mysite/mpdf60/'

    PHP_PATH = 'php'
    MPDF_SCRIPT = '{}/booktype2mpdf.php'.format(BOOKTYPE_ROOT)


    That's about it. More or less :)

    Aco
    Post edited by Aleksandar Erkalović at 2015-11-10 18:34:14
  • Thanks for helping me.

    I tried with your solution, and I have quite the same pb :

    [2015-11-11 17:24:26,775: INFO/MainProcess] Received task: booktype.apps.edit.tasks.publish_book[aeb65648-ffab-475e-8a83-c5a1251fc368]
    [2015-11-11 17:24:26,804: INFO/Worker-1] Starting new HTTP connection (1): booktype.********.fr
    [2015-11-11 17:24:26,820: ERROR/Worker-1] Connection error when loading http://booktype.********.fr/_convert/.
    Traceback (most recent call last):
      File "/var/www/bt/Booktype/lib/booktype/utils/download.py", line 28, in fetch_url
        req = requests.post(url, headers=headers, data=json.dumps(data))
      File "/usr/lib/python2.7/dist-packages/requests/api.py", line 88, in post
        return request('post', url, data=data, **kwargs)
      File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
        return session.request(method=method, url=url, **kwargs)
      File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in send
        r = adapter.send(request, **kwargs)
      File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
        raise ConnectionError(e)
    ConnectionError: HTTPConnectionPool(host='booktype.*********.fr', port=80): Max retries exceeded with url: /_convert/ (Caused by <class 'socket.error'>: [Errno 111] Connection refused)
    [2015-11-11 17:24:26,852: ERROR/MainProcess] Task booktype.apps.edit.tasks.publish_book[aeb65648-ffab-475e-8a83-c5a1251fc368] raised unexpected: UnboundLocalError("local variable 'req' referenced before assignment",)
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
        R = retval = fun(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
        return self.run(*args, **kwargs)
      File "/var/www/bt/Booktype/lib/booktype/apps/edit/tasks.py", line 99, in publish_book
        result = download.fetch_url(convert_url, data, method='POST')
      File "/var/www/bt/Booktype/lib/booktype/utils/download.py", line 36, in fetch_url
        if req.status_code != 200:
    UnboundLocalError: local variable 'req' referenced before assignment

    I put * myself to the url.

    I'm sure ; I am not so far from the solution.

    Thanks.

    Ph A
  • I have managed to get Booktype 2.0 installed and running at http://folketsforlag.org

    Main problem is when I try to export a book, no matter what format I choose, it says "Exporting, please wait...", and then nothing happens

    I have followed every step in the main tutorial http://sourcefabric.booktype.pro/booktype-20-for-authors-and-publishers/_draft/_v/1.0/installation-on-gnulinux/

    I have followed Alexandar's updated instructions two comments above at https://forum.sourcefabric.org/discussion/comment/33546#Comment_33546

    I had a problem getting Celery to work, I got this error:

    $ sudo supervisorctl status
    celery FATAL Exited too quickly (process log may have details)

    I corrected the Celery error by following this tutorial: http://jefurii.cafejosti.net/celery-in-virtualenv-with-supervisord.html so now it works

    I have checked, again and again that the path configurations are correct in base.py and prod.py
    specially:

    MPDF_DIR = '/var/www/mpdf60/' (even chown www-data on this one)

    PHP_PATH = 'php'
    MPDF_SCRIPT = '{}/booktype2mpdf.php'.format(BOOKTYPE_ROOT)

    and

    EXPORT_ALLOWED_HOSTS = ['127.0.0.1', '*']

    Made shure I have tidy installed as per this instruction in the main tutorial:

    apt-get install git-core python-dev python-pip libjpeg-dev libpq-dev libxml2-dev libxslt-dev rabbitmq-server redis-server tidy

    I wish someone could help me get this installation working, so I better can spend my time finishing the norwegian translation.


    Post edited by Graabein at 2015-11-13 06:49:02