0

启动交叉开关 0.12.1 时出现错误,而我在 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']

我没有更改交叉开关更新的任何其他内容。

我的 config.json 仍然是相同的,我的项目的 pythonpath 在选项中:

  {
     "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...

你有想法吗 ?谢谢。

4

2 回答 2

0

我与 Docker 合作是为了拥有一个干净的环境。这里的 Dockerfile:http ://crossbar.io/docs/Installation-on-Docker/似乎坏了:

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

它似乎解决了:

RUN pip install --upgrade cffi

运行之前 pip install crossbar[all]

有了这个环境,我的问题就解决了:) 不知道为什么我之前会收到这个错误,但它是有效的。

非常感谢这里的所有人和 indexerror,“法语 python stackoverflow”:)

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

附言

这是我使用的干净的 Dockerfile:

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

使用 Django、flask 和/或您想要的所有依赖项,位于与 Docker 文件位于同一文件夹中的名为“requirements.txt”的文件中:

requirements.txt 前:

ipython
django
djangorestframework
djangorestframework-jwt
django-cors-headers
bottlenose
python-amazon-simple-product-api
python-dateutil
beautifulsoup4
datetime
mechanize
pytesseract
requests
于 2016-02-16T15:04:51.490 回答
0

它似乎"pythonpath": ["/myproject"]替换了您的 dist-packages 中的其他 python 路径配置。寻找一个添加 /myproject而不是替换当前路径设置的选项。

或者 - 将项目的路径添加到机器 python 路径中,并且不提供任何 python 路径的交叉开关,所以它会选择现有的路径。

类似的东西(取决于操作系统):

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

然后:

/home/username/path/to/myproject 
于 2016-02-09T12:12:49.727 回答