我有一个Django应用程序,可以在RunsslServer下运行良好,但是当我在Apache下运行它时,流量到达了该应用程序,但是“导入oracledB”会失败。我以前在使用cx_oracle(也抛出了Importerror),并将其旋转到OracledB,希望能解决该问题。
i尝试编译mod_wsgi.so(5.0.2),但我再次遇到了相同的错误。 任何建议?
这在RHEL 9,Python3.9
there是错误堆栈:
mod_wsgi (pid=3089442, process='transfer_artic', application='oitapps-dev.sjf.edu:8000|'): Loading Python script file '/var/www/transfer_artic_django/transfer_artic/transfer_artic/wsgi.py'.
mod_wsgi (pid=3089442): Failed to exec Python script file '/var/www/transfer_artic_django/transfer_artic/transfer_artic/wsgi.py'.
mod_wsgi (pid=3089442): Exception occurred processing WSGI script '/var/www/transfer_artic_django/transfer_artic/transfer_artic/wsgi.py'.
Traceback (most recent call last):
File "/var/www/transfer_artic_django/transfer_artic/transfer_artic/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/django/conf/__init__.py", line 102, in __getattr__
self._setup(name)
File "/var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/django/conf/__init__.py", line 89, in _setup
self._wrapped = Settings(settings_module)
File "/var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/django/conf/__init__.py", line 217, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/var/www/transfer_artic_django/transfer_artic/transfer_artic/settings.py", line 14, in <module>
import oracledb
File "/var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/oracledb/__init__.py", line 43, in <module>
from . import base_impl, thick_impl, thin_impl
ImportError: /var/www/transfer_artic_django/transfer_artic_django_venv/lib64/python3.9/site-packages/oracledb/base_impl.cpython-39-x86_64-linux-gnu.so: failed to map segment from shared object
要验证在此环境中安装的内容,因为Apache加载了它,我暂时将WSGI.PY更改为:
from pip._internal.operations import freeze
def application(environ, start_response):
pkgs = freeze.freeze()
status = '200 OK'
# output = b'Hello World!'
output = "\n".join(pkgs).encode('ascii')
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
this this Output:
asgiref==3.8.1
cffi==1.17.1
cryptography==44.0.0
Django==4.2.19
django-cors-headers==4.7.0
django-sslserver==0.22
Jinja2==3.1.5
MarkupSafe==3.0.2
mod_wsgi==5.0.2
oracledb==3.0.0
packaging==24.2
pip==21.3.1
pycparser==2.22
pyOpenSSL==25.0.0
setuptools==53.0.0
sqlparse==0.5.3
typing_extensions==4.12.2
wsgi.py回到:
"""
WSGI config for transfer_artic project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'transfer_artic.settings')
application = get_wsgi_application()
...我有同样的问题-doh ...事实证明这是一个selinux configuraiton问题。
i发现,“ sudo setenforce 0”允许文件正确加载。
现在我只需要让我的系统管理员调整SelinuxConfig.