Crossbar 0.12.1 : No module named django - wsgi error

358 Views Asked by At

I get an error while i launch crossbar 0.12.1 that I did not have with the version 0.11

[Controller 210] crossbar.error.invalid_configuration: 
WSGI app module 'myproject.wsgi' import failed: No module named django - 
Python search path was [u'/myproject', '/opt/crossbar/site-packages/crossbar/worker', '/opt/crossbar/bin', '/opt/crossbar/lib_pypy/extensions', '/opt/crossbar/lib_pypy', '/opt/crossbar/lib-python/2.7', '/opt/crossbar/lib-python/2.7/lib-tk', '/opt/crossbar/lib-python/2.7/plat-linux2', '/opt/crossbar/site-packages']

I have not changed anything else that the crossbar update.

My config.json are still the same, with the pythonpath of my project within the option :

  {
     "workers": [
        {
           "type": "router",
           "options": {
               "pythonpath": ["/myproject"]
           },
           "realms": [
              {
                 "name": "realm1",
                 "roles": [
                    {
                       "name": "anonymous",
                       "permissions": [
                          {
                             "uri": "*",
                             "publish": true,
                             "subscribe": true,
                             "call": true,
                             "register": true
                          }
                       ]
                    }
                 ]
              }
           ],
           "transports": [
              {
                 "type": "web",
                 "endpoint": {
                    "type": "tcp",
                    "port": 80
                 },
                 "paths": {
                    "/": {
                       "type": "wsgi",
                       "module": "myproject.wsgi",
                       "object": "application"
                    },
etc...

Do you have an idea ? Thanks.

2

There are 2 best solutions below

4
On

It seems that "pythonpath": ["/myproject"] replaces other python path configs from your dist-packages. Look for an option that adds /myproject and not replacing current path settings.

Or - add the path to your project to the machine python path, and don't provide crossbar with any python path, so it will pick the exisitng one.

Something like (depends on OS):

$ sudo nano /usr/lib/python2.7/dist-packages/myproject.pth

Then:

/home/username/path/to/myproject 
0
On

I work with Docker in order to have a clean environment. The Dockerfile here : http://crossbar.io/docs/Installation-on-Docker/ seem broken :

ImportError: No module named setuptools_ext

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-VfPnRU/pynacl
Storing debug log for failure in /root/.pip/pip.log
The command '/bin/sh -c pip install crossbar[all]' returned a non-zero code: 1

it seem solved with :

RUN pip install --upgrade cffi

Before RUN pip install crossbar[all]

With this Environment, my problem are solved :) Don't know why i get this error before, but it's work.

Many thanks to all here and to indexerror, the "french python stackoverflow" :)

http://indexerror.net/3380/crossbar-0-12-1-wsgi-error-no-module-named-django?show=3415

P.S.

Here the clean Dockerfile i use :

FROM ubuntu
ENV APPNAME="monappli"

ADD requirements.txt /tmp/

RUN apt-get update
RUN apt-get install -y gcc build-essential python-dev python2.7-dev libxslt1-dev libssl-dev libxml2 libxml2-dev tesseract-ocr python-imaging libffi-dev libreadline-dev libbz2-dev libsqlite3-dev libncurses5-dev python-mysqldb python-pip

RUN cd /tmp/ && pip install -r requirements.txt
RUN pip install -U crossbar[all]

WORKDIR $APPNAME

CMD cd / && cd $APPNAME && python manage.py makemigrations && python manage.py migrate && crossbar start

With Django, flask and/or all the dependencies you want within a file named "requirements.txt" in the same folder than the Docker file :

requirements.txt ex :

ipython
django
djangorestframework
djangorestframework-jwt
django-cors-headers
bottlenose
python-amazon-simple-product-api
python-dateutil
beautifulsoup4
datetime
mechanize
pytesseract
requests