作者:无与伦比的美丽MJ | 来源:互联网 | 2023-01-30 14:51
我如何获得为Python 3.6.1编译的Apache2的mod_wsgi?
(或任何未来的Python版本)
我正在使用带有Django 1.11的Python 3.6.1虚拟环境,并且Everything正在根据Apache错误日志工作,除了Apache 2.4的mod_wsgi是为Python/3.5.1 +编译的并使用Python/3.5.2所以我的Python 3.6 .1代码失败,因为我使用的是3.5.2中没有的新功能
设置我的系统所涉及的所有其他配置和安装似乎都很好(在守护进程模式下运行)虽然mod_wsgi似乎没有使用我的Python 3.6.1虚拟环境(尽管它试图将它用于Django根据到错误日志)...
我用过: sudo apt-get install libapache2-mod-wsgi-py3
为Apache 2.4安装mod_wsgi
我用: ./configure --with-python=/usr/local/bin/python3.6
和make
同make install
为Python的3.6安装mod_wsgi的
我一定做错了 - 请纠正我!
这是我的Apache错误日志(清理了一下) - 是的我知道它在f""字符串行上失败了(python 3.6功能不在3.5中)
[wsgi:warn] mod_wsgi: Compiled for Python/3.5.1+.
[wsgi:warn] mod_wsgi: Runtime using Python/3.5.2.
[wsgi:warn] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[wsgi:warn] AH00094: Command line: '/usr/sbin/apache2'
[wsgi:error] mod_wsgi (pid=12963): Target WSGI script '/home/jamin/www/dev.tir.com/tir/tir/wsgi.py' cannot be loaded as Python module.
[wsgi:error] mod_wsgi (pid=12963): Exception occurred processing WSGI script '/home/jamin/www/dev.tir.com/tir/tir/wsgi.py'.
[wsgi:error] Traceback (most recent call last):
[wsgi:error] File "/home/jamin/www/dev.tir.com/tir/tir/wsgi.py", line 21, in
[wsgi:error] application = get_wsgi_application()
[wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[wsgi:error] django.setup(set_prefix=False)
[wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
[wsgi:error] apps.populate(settings.INSTALLED_APPS)
[wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/apps/registry.py", line 116, in populate
[wsgi:error] app_config.ready()
[wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready
[wsgi:error] self.module.autodiscover()
[wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
[wsgi:error] autodiscover_modules('admin', register_to=site)
[wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
[wsgi:error] import_module('%s.%s' % (app_config.name, module_to_search))
[wsgi:error] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
[wsgi:error] return _bootstrap._gcd_import(name[level:], package, level)
[wsgi:error] File "", line 986, in _gcd_import
[wsgi:error] File "", line 969, in _find_and_load
[wsgi:error] File "", line 958, in _find_and_load_unlocked
[wsgi:error] File "", line 673, in _load_unlocked
[wsgi:error] File "", line 665, in exec_module
[wsgi:error] File "", line 222, in _call_with_frames_removed
[wsgi:error] File "/home/jamin/www/dev.tir.com/tir/company/admin.py", line 13, in
[wsgi:error] from .forms import AdminInteractionForm
[wsgi:error] File "/home/jamin/www/dev.tir.com/tir/company/forms.py", line 87
[wsgi:error] resp = f"Hi {user.first_name}, you'll need to login to send any more suggestions. \\
[wsgi:error] \\n\\nFirst Time? Check your email/spam for login instructions from us."
[wsgi:error]
[wsgi:error] ^
[wsgi:error] SyntaxError: invalid syntax
*tir.com也是我实际网站的简写 - 我与该域名没有任何关系
1> Graham Dumpl..:
请执行下列操作.
卸载系统mod_wsgi包.
sudo apt-get remove libapache2-mod-wsgi-py3
使用pip
,最好安装到Python虚拟环境中的mod_wsgi .确保pip
是您要使用的Python版本.
pip install mod_wsgi
显示要添加到Apache配置文件的配置,以通过运行以下命令加载此mod_wsgi:
mod_wsgi-express module-config
获取上面命令的输出以显示config并添加到Apache配置.
将配置添加到Apache以加载hello world WSGI应用程序以测试它的工作原理.
查看pip
基于安装的详细信息:
https://pypi.python.org/pypi/mod_wsgi
@palewire创建一个新问题.但是,如果你环顾四周,并阅读PyPi上的文档,你会发现它是因为你还没有为Apache安装dev包.请参阅https://pypi.org/project/mod_wsgi/,如果没有找到``apxs``.这条消息甚至说得那么多.
2> Arbab Nazar..:
当我使用@Graham Dumpleton建议来安装mod_wsgi
使用时pip
,得到了这个错误:
RuntimeError: The 'apxs' command appears not to be installed or is not executable.
Please check the list of prerequisites in the documentation for this package and
install any missing Apache httpd server packages.
要成功编译并安装mod_wsgi
through pip
,我需要apache2-dev
在Ubuntu上安装软件包:
sudo apt-get install -y apache2-dev
之后pip install mod_wsgi
成功完成.
希望可以帮助别人.