Uwsgi与miniconda2 env给出ImportError:无法导入名称_compare_digest

时间:2015-12-16 15:17:32

标签: python pip uwsgi anaconda conda

我有一个在miniconda2环境中运行的烧瓶服务。我用

安装了uwsgi系统
sudo pip install uwsgi

现在,当我尝试使用uwsgi启动我的服务时。

uwsgi --socket 127.0.0.1:5000 --protocol=http --home /home/ankit/miniconda2/envs/venv -w wsgi.py

它给了我以下错误。

*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./wsgi.py", line 1, in <module>
    from wait_prediction_api import app
  File "./wait_prediction_api.py", line 1, in <module>
    from flask import Flask,jsonify,request,abort,make_response
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/flask/__init__.py", line 21, in <module>
    from .app import Flask, Request, Response
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/flask/app.py", line 26, in <module>
    from . import json
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/flask/json.py", line 25, in <module>
    from itsdangerous import json as _json
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/itsdangerous.py", line 14, in <module>
    import hmac
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/hmac.py", line 8, in <module>
    from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
unable to load app 0 (mountpoint='') (callable not found or import error)*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./wsgi.py", line 1, in <module>
    from wait_prediction_api import app
  File "./wait_prediction_api.py", line 1, in <module>
    from flask import Flask,jsonify,request,abort,make_response
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/flask/__init__.py", line 21, in <module>
    from .app import Flask, Request, Response
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/flask/app.py", line 26, in <module>
    from . import json
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/flask/json.py", line 25, in <module>
    from itsdangerous import json as _json
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/site-packages/itsdangerous.py", line 14, in <module>
    import hmac
  File "/home/ankit/miniconda2/envs/venv/lib/python2.7/hmac.py", line 8, in <module>
    from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
unable to load app 0 (mountpoint='') (callable not found or import error)

1 个答案:

答案 0 :(得分:0)

尝试-w wsgi:<app>,其中<app>是wsgi.py文件中Flask应用程序的名称。

或使用更明确的

--wsgi-file wsgi.py --callable app