在 anaconda虛擬環境 python3.3 bottle 連接 Apache WSGI

发布于 2022-09-04 11:34:08 字数 3243 浏览 13 评论 0

我的环境如下
OS:Ubuntu 15.10
程式库:Anaconda 4.2.13(打包所有开发python的环境,使用conda指令建立python 虚拟环境)
python版本:3.3(虚拟环境),在OS里其版本为2.7.10
Web Server:apache2.4.12
wsgi:libapache2-mod-wsgi (4.3.0-1build1)

实作方式为
在/var/www/test有home.wsgi测试档

import bottle

application = bottle.default_app()

@bottle.route('/')
def home():
    return "apache and wsgi, setting in a tree"

apache需连接python的指令码,实作如下
在/etc/apache2/sites-available/000-default.conf <VirtualHost>那一段添加一行

WSGIScriptAlias / /var/www/test/home.wsgi

效果为在localhost页面需出现
apache and wsgi, setting in a tree

但目前页面出现Internal Server Error,查看apache2 error log的结果,推测为apache连结的wsgi为python 2.7.10的wsgi,想请问如何在conda的虚拟环境中创造自身符合当下python版本的wsgi,如无法,怎么自建一个虚拟布署环境可以配合当下程式库的版本?

error log 如下,如推测有误,请各位多多指教

[Tue Jan 31 23:41:26.695740 2017] [wsgi:error] [pid 699:tid 140257444968192] [client 127.0.0.1:40028] Traceback (most recent call last):
[Tue Jan 31 23:41:26.695954 2017] [wsgi:error] [pid 699:tid 140257444968192] [client 127.0.0.1:40028]   File "/var/www/test/home.wsgi", line 1, in <module>
[Tue Jan 31 23:41:26.695972 2017] [wsgi:error] [pid 699:tid 140257444968192] [client 127.0.0.1:40028]     import bottle
[Tue Jan 31 23:41:26.696018 2017] [wsgi:error] [pid 699:tid 140257444968192] [client 127.0.0.1:40028] ImportError: No module named 'bottle'
[Tue Jan 31 23:42:57.812442 2017] [mpm_event:notice] [pid 695:tid 140257541449600] AH00491: caught SIGTERM, shutting down
[Tue Jan 31 23:42:58.811791 2017] [mpm_event:notice] [pid 1053:tid 140030973994880] AH00489: Apache/2.4.12 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.10 configured -- resuming normal operations
[Tue Jan 31 23:42:58.811869 2017] [core:notice] [pid 1053:tid 140030973994880] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jan 31 23:43:16.012357 2017] [mpm_event:notice] [pid 1053:tid 140030973994880] AH00491: caught SIGTERM, shutting down
[Tue Jan 31 23:43:17.095085 2017] [mpm_event:notice] [pid 1188:tid 140582090012544] AH00489: Apache/2.4.12 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.10 configured -- resuming normal operations
[Tue Jan 31 23:43:17.095227 2017] [core:notice] [pid 1188:tid 140582090012544] AH00094: Command line: '/usr/sbin/apache2'
[Tue Jan 31 23:44:30.199698 2017] [wsgi:error] [pid 1191:tid 140581960972032] [client 127.0.0.1:40052] mod_wsgi (pid=1191): Target WSGI script '/var/www/test/home.wsgi' cannot be loaded as Python module.
[Tue Jan 31 23:44:30.199807 2017] [wsgi:error] [pid 1191:tid 140581960972032] [client 127.0.0.1:40052] mod_wsgi (pid=1191): Exception occurred processing WSGI script '/var/www/test/home.wsgi'.
[Tue Jan 31 23:44:30.199841 2017] [wsgi:error] [pid 1191:tid 140581960972032] [client 127.0.0.1:40052] Traceback (most recent call last):
[Tue Jan 31 23:44:30.199872 2017] [wsgi:error] [pid 1191:tid 140581960972032] [client 127.0.0.1:40052]   File "/var/www/test/home.wsgi", line 1, in <module>
[Tue Jan 31 23:44:30.199982 2017] [wsgi:error] [pid 1191:tid 140581960972032] [client 127.0.0.1:40052]     import bottle
[Tue Jan 31 23:44:30.200013 2017] [wsgi:error] [pid 1191:tid 140581960972032] [client 127.0.0.1:40052] ImportError: No module named bottle

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文