Ubuntu 14.04 ( python 3.4 ),使用Apache2和 libapache2 mod wsgi py3 AssertionError

分享于 

3分钟阅读

ubuntu

  繁體

问题

在Ubuntu 14.04上,Apache2与libapache2-mod-wsgi-py3一起使用,在/var/log/apache2/error.log中给出错误


sudo apt-get install apache2


sudo service apache2 restart


# /var/log/apache2/error.log is"clean"


sudo apt-get install libapache2-mod-wsgi-py3


sudo service apache2 restart



/var/log/apache2/error.log给出以下错误:


[Mon Jan 05 16:51:53.641332 2015] [:error] [pid 3141:tid 140703516379008] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>


[Mon Jan 05 16:51:53.643563 2015] [:error] [pid 3141:tid 140703516379008] Traceback (most recent call last):


[Mon Jan 05 16:51:53.643633 2015] [:error] [pid 3141:tid 140703516379008] File"/usr/lib/python3.4/threading.py", line 1288, in _shutdown


[Mon Jan 05 16:51:53.644350 2015] [:error] [pid 3141:tid 140703516379008] assert tlock is not None


[Mon Jan 05 16:51:53.643449 2015] [:error] [pid 3140:tid 140703516379008] Exception ignored in: <module 'threading' from '/usr/lib/python3.4/threading.py'>


[Mon Jan 05 16:51:53.644456 2015] [:error] [pid 3140:tid 140703516379008] Traceback (most recent call last):


[Mon Jan 05 16:51:53.644514 2015] [:error] [pid 3140:tid 140703516379008] File"/usr/lib/python3.4/threading.py", line 1288, in _shutdown


[Mon Jan 05 16:51:53.645052 2015] [:error] [pid 3140:tid 140703516379008] assert tlock is not None


[Mon Jan 05 16:51:53.645119 2015] [:error] [pid 3141:tid 140703516379008] AssertionError: 


[Mon Jan 05 16:51:53.647513 2015] [:error] [pid 3140:tid 140703516379008] AssertionError: 




答案1

Ubuntu 14.04附带mod_wsgi 3.4,

1)删除有问题的软件包,并安装依赖性


sudo apt-get remove libapache2-mod-wsgi-py3


sudo apt-get install apache2-dev



2)使用pip在virtualenv安装mod_wsgi


. /venv_path/bin/activate


pip install mod_wsgi



3)安装到Apache (系统范围)


sudo /venv_path/bin/mod_wsgi-express install-module


sudo vi /etc/apache2/mods-available/wsgi_express.load /etc/apache2/mods-available/wsgi_express.conf



内容:/etc/apache2/mods-available/wsgi_express.load


LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py34.cpython-34m.so



内容:/etc/apache2/mods-available/wsgi_express.conf


WSGIPythonHome /venv_path



4)启用模块,并重新启动Apache。


sudo a2enmod wsgi_express


sudo service apache2 restart



5)检查/var/log/apache2/error.log中没有错误



Ubuntu  Apache  Assert  断言  python-3  WSGI