如何修复不同的 python 版本错误?
How to fix different python versions errors?
我有 3 个不同的版本:
2.7, 3.5, 3.6
要安装 Flask 和 运行 Hello World,我是按照这个教程一步一步来的 Flask
但我将此命令 ln -sf /usr/bin/python3 /usr/bin/python
更改为:
ln -sf /usr/bin/python3.6 /usr/bin/python
现在它在日志中给我这个错误:
[Fri Apr 20 09:21:19.808894 2018] [mpm_event:notice] [pid 25752:tid 139701099587456] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 09:21:19.808980 2018] [core:notice] [pid 25752:tid 139701099587456] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:21:32.207980 2018] [mpm_event:notice] [pid 25752:tid 139701099587456] AH00491: caught SIGTERM, shutting down
[Fri Apr 20 09:21:33.319127 2018] [wsgi:warn] [pid 26013:tid 140126648674176] mod_wsgi: Compiled for Python/3.5.1+.
[Fri Apr 20 09:21:33.319205 2018] [wsgi:warn] [pid 26013:tid 140126648674176] mod_wsgi: Runtime using Python/3.5.2.
[Fri Apr 20 09:21:33.320002 2018] [mpm_event:notice] [pid 26013:tid 140126648674176] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 20 09:21:33.320024 2018] [core:notice] [pid 26013:tid 140126648674176] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:28:37.277698 2018] [mpm_event:notice] [pid 26013:tid 140126648674176] AH00491: caught SIGTERM, shutting down
[Fri Apr 20 09:28:38.336490 2018] [wsgi:warn] [pid 10166:tid 140069159778176] mod_wsgi: Compiled for Python/3.5.1+.
[Fri Apr 20 09:28:38.336542 2018] [wsgi:warn] [pid 10166:tid 140069159778176] mod_wsgi: Runtime using Python/3.5.2.
[Fri Apr 20 09:28:38.337272 2018] [mpm_event:notice] [pid 10166:tid 140069159778176] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 20 09:28:38.337294 2018] [core:notice] [pid 10166:tid 140069159778176] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:29:08.182299 2018] [mpm_event:notice] [pid 10166:tid 140069159778176] AH00491: caught SIGTERM, shutting down
[Fri Apr 20 09:29:09.224956 2018] [wsgi:warn] [pid 10290:tid 140446016731008] mod_wsgi: Compiled for Python/3.5.1+.
[Fri Apr 20 09:29:09.225001 2018] [wsgi:warn] [pid 10290:tid 140446016731008] mod_wsgi: Runtime using Python/3.5.2.
[Fri Apr 20 09:29:09.225714 2018] [mpm_event:notice] [pid 10290:tid 140446016731008] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 20 09:29:09.225740 2018] [core:notice] [pid 10290:tid 140446016731008] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:29:42.886467 2018] [wsgi:error] [pid 10294:tid 140445919373056] [client 134.193.130.121:56046] mod_wsgi (pid=10294): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python modul$
[Fri Apr 20 09:29:42.886529 2018] [wsgi:error] [pid 10294:tid 140445919373056] [client 134.193.130.121:56046] mod_wsgi (pid=10294): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
我的理解是找不到 Flask 模块。我又换了版本,现在迷路了。怎么做才能让 "Hello World"
工作?
这些日志不显示实际错误以及您的应用未加载的原因。您需要查看包含内容后的消息。
有关 Python 补丁级别的警告可以忽略,如以下位置所述:
如果您想使用 Python 3.6,您必须使用已为 3.6 编译的 mod_wsgi 安装。无法强制为 3.5 编译的 mod_wsgi 使用 3.6。
您应该卸载 mod_wsgi 的系统包。然后根据 Python 3.6 自己从源代码编译 mod_wsgi 并使用它。最简单的pip install
方法:
然后 运行 mod_wsgi-express module-config
获取要包含在 Apache 配置中的配置。如果只是进行本地开发,则使用 mod_wsgi-express start-server
。请参阅 link.
处的文档
您不能将 pyenv
与 mod_wsgi 一起使用,除非您采取额外的步骤以确保 pyenv
为 Python 生成共享库,但它不会这样做默认。
我有 3 个不同的版本:
2.7, 3.5, 3.6
要安装 Flask 和 运行 Hello World,我是按照这个教程一步一步来的 Flask
但我将此命令 ln -sf /usr/bin/python3 /usr/bin/python
更改为:
ln -sf /usr/bin/python3.6 /usr/bin/python
现在它在日志中给我这个错误:
[Fri Apr 20 09:21:19.808894 2018] [mpm_event:notice] [pid 25752:tid 139701099587456] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 09:21:19.808980 2018] [core:notice] [pid 25752:tid 139701099587456] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:21:32.207980 2018] [mpm_event:notice] [pid 25752:tid 139701099587456] AH00491: caught SIGTERM, shutting down
[Fri Apr 20 09:21:33.319127 2018] [wsgi:warn] [pid 26013:tid 140126648674176] mod_wsgi: Compiled for Python/3.5.1+.
[Fri Apr 20 09:21:33.319205 2018] [wsgi:warn] [pid 26013:tid 140126648674176] mod_wsgi: Runtime using Python/3.5.2.
[Fri Apr 20 09:21:33.320002 2018] [mpm_event:notice] [pid 26013:tid 140126648674176] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 20 09:21:33.320024 2018] [core:notice] [pid 26013:tid 140126648674176] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:28:37.277698 2018] [mpm_event:notice] [pid 26013:tid 140126648674176] AH00491: caught SIGTERM, shutting down
[Fri Apr 20 09:28:38.336490 2018] [wsgi:warn] [pid 10166:tid 140069159778176] mod_wsgi: Compiled for Python/3.5.1+.
[Fri Apr 20 09:28:38.336542 2018] [wsgi:warn] [pid 10166:tid 140069159778176] mod_wsgi: Runtime using Python/3.5.2.
[Fri Apr 20 09:28:38.337272 2018] [mpm_event:notice] [pid 10166:tid 140069159778176] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 20 09:28:38.337294 2018] [core:notice] [pid 10166:tid 140069159778176] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:29:08.182299 2018] [mpm_event:notice] [pid 10166:tid 140069159778176] AH00491: caught SIGTERM, shutting down
[Fri Apr 20 09:29:09.224956 2018] [wsgi:warn] [pid 10290:tid 140446016731008] mod_wsgi: Compiled for Python/3.5.1+.
[Fri Apr 20 09:29:09.225001 2018] [wsgi:warn] [pid 10290:tid 140446016731008] mod_wsgi: Runtime using Python/3.5.2.
[Fri Apr 20 09:29:09.225714 2018] [mpm_event:notice] [pid 10290:tid 140446016731008] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 20 09:29:09.225740 2018] [core:notice] [pid 10290:tid 140446016731008] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 09:29:42.886467 2018] [wsgi:error] [pid 10294:tid 140445919373056] [client 134.193.130.121:56046] mod_wsgi (pid=10294): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python modul$
[Fri Apr 20 09:29:42.886529 2018] [wsgi:error] [pid 10294:tid 140445919373056] [client 134.193.130.121:56046] mod_wsgi (pid=10294): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
我的理解是找不到 Flask 模块。我又换了版本,现在迷路了。怎么做才能让 "Hello World"
工作?
这些日志不显示实际错误以及您的应用未加载的原因。您需要查看包含内容后的消息。
有关 Python 补丁级别的警告可以忽略,如以下位置所述:
如果您想使用 Python 3.6,您必须使用已为 3.6 编译的 mod_wsgi 安装。无法强制为 3.5 编译的 mod_wsgi 使用 3.6。
您应该卸载 mod_wsgi 的系统包。然后根据 Python 3.6 自己从源代码编译 mod_wsgi 并使用它。最简单的pip install
方法:
然后 运行 mod_wsgi-express module-config
获取要包含在 Apache 配置中的配置。如果只是进行本地开发,则使用 mod_wsgi-express start-server
。请参阅 link.
您不能将 pyenv
与 mod_wsgi 一起使用,除非您采取额外的步骤以确保 pyenv
为 Python 生成共享库,但它不会这样做默认。