使用带有Conda环境的uwsgi问题

时间:2016-01-11 14:57:39

标签: python flask uwsgi supervisord conda

我正在尝试使用uwsgi在conda环境中运行Flask应用程序,由主管启动。

我的uwsgi配置文件看起来像

myflaskapp.ini

[uwsgi]
uid = 1001
gid = 1001
master = true
processes = 2
chmod-socket = 666
pid-file = /home/me/Development/flask/myflaskapp/run/myflaskapp.pid
socket = /home/me/Development/flask/myflaskapp/run/myflaskapp.sock
module = wsgi
callable = app
logdate = true

并且超级用户配置文件看起来像

uwsgi-myflaskapp.conf

[program:uwsgi-myflaskapp]
command=/home/me/Development/miniconda/envs/myenv/bin/uwsgi /home/me/Development/flask/myflaskapp/myflaskapp.ini
autostart=true
autorestart=true
stdout_logfile=/home/me/Development/flask/myflaskapp/log/uwsgi-myflaskapp.log
redirect_stderr=true
exitcodes=0

重新加载主管(sudo supervisorctl reload)时,我在日志文件中收到以下错误:

Mon Jan 11 15:48:29 2016 - Python version: 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:08:32)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 578, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 524, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 408, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

第一个问题:为什么在conda环境中使用/usr/lib/python2.7而不是Python?在supervisor配置中使用我的conda环境中的uwsgi bin来设置conda环境是不够的?如果没有,我该如何设置conda环境?

第二个问题:我该如何解决这个错误?

0 个答案:

没有答案