Django - how to correctly install library without pip in venv to work after deployment
Asked Answered
V

1

0

According to this guide I successfully connected to Sybase database in my django project in virtual environment.

After deployment in Apache the web writes this error message

Environment:


Request Method: GET
Request URL: http://localhost:8080/

Django Version: 1.8
Python Version: 3.6.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'blog',
 'sybase_app')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')


Traceback:
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.6/contextlib.py" in inner
  51.             with self._recreate_cm():
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/transaction.py" in __enter__
  150.             if not connection.get_autocommit():
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in get_autocommit
  286.         self.ensure_connection()
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  130.                 self.connect()
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/utils.py" in __exit__
  97.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/utils/six.py" in reraise
  658.             raise value.with_traceback(tb)
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  130.                 self.connect()
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in connect
  118.         conn_params = self.get_connection_params()
File "/home/pd/sibp/env/lib/python3.6/site-packages/sqlany_django/base.py" in get_connection_params
  517.         root = Database.Root('PYTHON')
File "/home/pd/sibp/env/lib/python3.6/site-packages/sqlanydb.py" in __init__
  466.                                 'libdbcapi_r.dylib')
File "/home/pd/sibp/env/lib/python3.6/site-packages/sqlanydb.py" in load_library
  458.     raise InterfaceError("Could not load dbcapi.  Tried: " + ','.join(map(str, names)))

Exception Type: InterfaceError at /
Exception Value: Could not load dbcapi.  Tried: None,dbcapi.dll,libdbcapi_r.so,libdbcapi_r.dylib

I edited /etc/apache2/envvars and appended a line export LD_LIBRARY_PATH=/opt/sqlanywhere17/lib64:/opt/sqlanywhere17/lib32:$LD_LIBRARY_PATH

The error message changed to:

Environment:


Request Method: GET
Request URL: http://localhost:8080/

Django Version: 1.8
Python Version: 3.6.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'blog',
 'sybase_app')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')


Traceback:
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.6/contextlib.py" in inner
  51.             with self._recreate_cm():
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/transaction.py" in __enter__
  150.             if not connection.get_autocommit():
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in get_autocommit
  286.         self.ensure_connection()
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  130.                 self.connect()
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/utils.py" in __exit__
  97.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/utils/six.py" in reraise
  658.             raise value.with_traceback(tb)
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  130.                 self.connect()
File "/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py" in connect
  118.         conn_params = self.get_connection_params()
File "/home/pd/sibp/env/lib/python3.6/site-packages/sqlany_django/base.py" in get_connection_params
  517.         root = Database.Root('PYTHON')
File "/home/pd/sibp/env/lib/python3.6/site-packages/sqlanydb.py" in __init__
  480.                         API_VERSION_EX)

Exception Type: InterfaceError at /
Exception Value: Failed to initalize dbcapi context, dbcapi version 2 required. Perhaps you are missing some sqlanywhere libaries?

How can I fix it?

Vtarj answered 9/2, 2022 at 17:54 Comment(0)
V
1

I solved it, so that I appended the file /opt/sqlanywhere17/bin64/sa_config.sh to /etc/apache2/envvars and restarted apache2.

Vtarj answered 10/2, 2022 at 6:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.