我无法在debian上正确设置带有uwsgi的瓶子应用程序

时间:2015-10-18 02:06:16

标签: debian virtualenv uwsgi bottle

我正在尝试设置一个Bottle的应用程序。

我在Debian 8(Jessie)上使用python2.7和3.4以及从APT安装的uwsgi。我当前的应用程序在python3.4下运行,我为此目的创建了一个VirtualEnv。

当我重新加载uwsgi服务时出现问题,它没有找到virtualenv中安装的正确模块。但是我在uwsgi .ini文件中有“virtualenv”条目。

更新

感谢@AngelVelásquez,我修正了错字,但问题还在继续。

我看到uWSGI忽略了virtualenv上安装的python版本,并尝试使用默认系统的python版本运行应用程序。

我如何让这个环境开始起作用?

的config.ini

[uwsgi]
plugins = python3
virtualenv = /srv/virtualenv/donde
pythonpath = /srv/virtualenv/donde/lib/python3.4/site-packages
no-site = True

uid = www-data
gid = www-data
chdir = /srv/http/donde
file = app.py
processes = 2
threads = 2

输出

Sat Oct 17 23:35:30 2015 - added /srv/virtualenv/donde/lib/python3.4/site-packages/ to pythonpath.
Traceback (most recent call last):
  File "app.py", line 1, in <module>
    from bottle import Bottle, request, abort, template, static_file, jinja2_view
  File "/srv/virtualenv/donde/lib/python3.4/site-packages/bottle.py", line 16, in <module>
    from __future__ import with_statement
ImportError: No module named __future__
Sat Oct 17 23:35:30 2015 - unable to load app 0 (mountpoint='') (callable not found or import error)

原始设置

当我将“pythonpath”条目与virtualenv的site-packages路径放在一起时,问题变得“解决”。

这是正确的方法吗?为什么uwsgi忽略了“virtualenv”条目?

谢谢,对不起我丑陋的英语!

的config.ini

[uwsgi]
plugins = python3
virualenv = /srv/virtualenv/donde
uid = www-data
gid = www-data
chdir = /srv/http/donde
file = app.py
processes = 2
threads = 2

输出:

Sat Oct 17 22:57:48 2015 - *** Operational MODE: preforking+threaded ***
Traceback (most recent call last):
  File "app.py", line 1, in <module>
    from bottle import Bottle, request, abort, template, static_file, jinja2_view
ImportError: No module named bottle
Sat Oct 17 22:57:48 2015 - unable to load app 0 (mountpoint='') (callable not found or import error)
Sat Oct 17 22:57:48 2015 - *** no app loaded. going in full dynamic mode ***
Sat Oct 17 22:57:48 2015 - *** uWSGI is running in multiple interpreter mode ***

丑陋的修复模式:

的config.ini

[uwsgi]
plugins = python3
virualenv = /srv/virtualenv/donde

pythonpath = /srv/virtualenv/donde/lib/python3.4/site-packages

uid = www-data
gid = www-data
chdir = /srv/http/donde
file = app.py
processes = 2
threads = 2

输出:

Sat Oct 17 23:00:58 2015 - *** Operational MODE: preforking+threaded ***
Sat Oct 17 23:00:58 2015 - added /srv/virtualenv/donde/lib/python3.4/site-packages/ to pythonpath.
Sat Oct 17 23:00:58 2015 - WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xce1000 pid: 19196 (default app)
Sat Oct 17 23:00:58 2015 - *** uWSGI is running in multiple interpreter mode ***

2 个答案:

答案 0 :(得分:2)

安装uwsgi-plugin-python3后,问题解决了:)

最终的config.ini就是这个

[uwsgi]
plugin = python3
virtualenv = /srv/virtualenv/donde

uid = www-data
gid = www-data
chdir = /srv/http/donde
file = app.py
processes = 2
threads = 2

答案 1 :(得分:1)

似乎你的配置上有拼写错误,它说的是virualenv而不是virtualenv