【发布时间】:2017-10-12 10:02:54
【问题描述】:
我想将 python 3.5 与瓶子和 apache 一起使用。
但是当我从浏览器访问adapter.wsgi时,
内部服务器错误
▼error_log
[error] ImportError: No module named os
[error] ImportError: No module named bottle
应用
▼/etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/rh/rh-python35/root/usr/bin/python3
<FilesMatch \.wsgi$>
SetHandler wsgi-script
Options +ExecCGI
</FilesMatch>
<FilesMatch \.py$>
SetHandler wsgi-script
Options +ExecCGI
</FilesMatch>
▼adapter.wsgi
# -*- coding:utf-8 -*-
import sys, os
dirpath = os.path.dirname(os.path.abspath(__file__))
sys.path.append(dirpath)
os.chdir(dirpath)
import bottle
import index
application = bottle.default_app()
▼index.py
# -*- coding:utf-8 -*-
from bottle import route, run, template
from bottle import TEMPLATE_PATH
@route('/')
def index():
return "HELLO WORLD!"
if __name__ == '__main__':
run(host='hogetest.com', port=80, debug=True, reloader=True)
现状
$ python -V
Python 3.5.1
$ which python
别名 python='/opt/rh/rh-python35/root/usr/bin/python3'
/opt/rh/rh-python35/root/usr/bin/python3
【问题讨论】:
-
那么您是在问如何删除python 2.6.6,因为您不使用它或如何修复ImportError?另外,如果你有 python 2.6.6 并且想要使用 python 3 模块并不重要,重要的是你使用哪个 python 解释器。
-
你不想删除预装系统python 2.6,它好吧导致问题
-
我想使用 Python 3 模块。我该如何解决这个错误?
标签: python apache mod-wsgi bottle