【问题标题】:Crossbar 0.12.1 : No module named django - wsgi errorCrossbar 0.12.1:没有名为 django 的模块 - wsgi 错误
【发布时间】:2016-02-09 10:59:17
【问题描述】:

我在启动交叉开关 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...

你有什么想法吗? 谢谢。

【问题讨论】:

  • >>> 导入 django 作品?
  • 是的。在 ./manage.py 外壳中。
  • 好的,看我的回答
  • 来自 python,没有 manage.py?
  • 是的,也来自 python、python2.7 和 ipython。

标签: django docker wamp wsgi crossbar


【解决方案1】:

似乎"pythonpath": ["/myproject"] 替换了您的 dist 包中的其他 python 路径配置。寻找添加 /myproject 且不替换当前路径设置的选项。

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

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

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

然后:

/home/username/path/to/myproject 

【讨论】:

  • 谢谢。我试过了,但不起作用。我得到“导入失败:没有名为 myproject 的模块”。 Crossbar 之前正确找到了 myproject 并且似乎加载了 wdgi.py,但找不到 django。很奇怪......仍在使用crossbar 0.11:/
  • 好的,也许是 myproject 的路径。
  • 这里的 wsgi 教程和交叉开关 0.12.1 存在同样的问题:crossbar.io/docs/WSGI-Host-Service" WSGI app module 'myapp' import failed: No module named flask"
  • 谢谢Oberstet,我会试试的:)
【解决方案2】:

我与 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-01
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 2015-08-06
    • 2012-07-16
    • 2020-01-15
    • 1970-01-01
    相关资源
    最近更新 更多