最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

django - ImportError for venvlib64python3.9site-packagesoracledbbase_impl.cpython-39-x86_64-linux-gnu.so - Stack Overflow

programmeradmin0浏览0评论

I have a Django app that runs fine under runsslserver, but when I run it under Apache, the traffic gets to the app, but 'import oracledb' fails. I was using cx_Oracle previously (which also threw an ImportError) and switiched to oracledb hoping that would solve the problem.

I tried compiling the mod_wsgi.so (5.0.2), but again I get the same error.

Any suggestions?

This is on RHEL 9, python 3.9

Here is error stack:

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

To verify what is installed in this environment, as Apache loads it, I temporarily change wsgi.py to:

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 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 is back to:

"""
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
.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()

...and I have the same issue

I have a Django app that runs fine under runsslserver, but when I run it under Apache, the traffic gets to the app, but 'import oracledb' fails. I was using cx_Oracle previously (which also threw an ImportError) and switiched to oracledb hoping that would solve the problem.

I tried compiling the mod_wsgi.so (5.0.2), but again I get the same error.

Any suggestions?

This is on RHEL 9, python 3.9

Here is error stack:

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

To verify what is installed in this environment, as Apache loads it, I temporarily change wsgi.py to:

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 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 is back to:

"""
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/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()

...and I have the same issue

Share Improve this question edited Mar 12 at 20:33 user2379881 asked Mar 11 at 20:07 user2379881user2379881 931 silver badge6 bronze badges 1
  • What's the complete error stack? Review github/oracle/python-oracledb/issues/… however this cryptography loading issue would not have occurred with cx_Oracle so it may not be relevant to your initial problem. – Christopher Jones Commented Mar 12 at 2:52
Add a comment  | 

1 Answer 1

Reset to default 0

DOH...This turns out to be an SELinux configuraiton issue.

I found that by 'sudo setenforce 0' allows the file to load properly.

Now I just have to get my system administrator to adjust the SELinux config.

发布评论

评论列表(0)

  1. 暂无评论