title: Django - how to correctly install library without pip in venv to work after deployment
body: <p>According to <a href="https://kcsharepoint.home.blog/2021/08/02/python-connect-to-sybase-sap-database-linux-based-os-only/" rel="nofollow noreferrer">this</a> guide I successfully connected to <code>Sybase</code> database in my django project in virtual environment.</p>
  <p>After deployment in <code>Apache</code> the web writes this error message</p>
  <pre><code>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 &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/core/handlers/base.py&quot; in get_response
    132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File &quot;/usr/lib/python3.6/contextlib.py&quot; in inner
    51.             with self._recreate_cm():
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/transaction.py&quot; in __enter__
    150.             if not connection.get_autocommit():
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in get_autocommit
    286.         self.ensure_connection()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in ensure_connection
    130.                 self.connect()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/utils.py&quot; in __exit__
    97.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/utils/six.py&quot; in reraise
    658.             raise value.with_traceback(tb)
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in ensure_connection
    130.                 self.connect()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in connect
    118.         conn_params = self.get_connection_params()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/sqlany_django/base.py&quot; in get_connection_params
    517.         root = Database.Root('PYTHON')
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/sqlanydb.py&quot; in __init__
    466.                                 'libdbcapi_r.dylib')
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/sqlanydb.py&quot; in load_library
    458.     raise InterfaceError(&quot;Could not load dbcapi.  Tried: &quot; + ','.join(map(str, names)))
  
  Exception Type: InterfaceError at /
  Exception Value: Could not load dbcapi.  Tried: None,dbcapi.dll,libdbcapi_r.so,libdbcapi_r.dylib
  </code></pre>
  <p>I edited <code>/etc/apache2/envvars</code> and appended a line
  <code>export LD_LIBRARY_PATH=/opt/sqlanywhere17/lib64:/opt/sqlanywhere17/lib32:$LD_LIBRARY_PATH</code></p>
  <p>The error message changed to:</p>
  <pre><code>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 &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/core/handlers/base.py&quot; in get_response
    132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File &quot;/usr/lib/python3.6/contextlib.py&quot; in inner
    51.             with self._recreate_cm():
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/transaction.py&quot; in __enter__
    150.             if not connection.get_autocommit():
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in get_autocommit
    286.         self.ensure_connection()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in ensure_connection
    130.                 self.connect()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/utils.py&quot; in __exit__
    97.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/utils/six.py&quot; in reraise
    658.             raise value.with_traceback(tb)
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in ensure_connection
    130.                 self.connect()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/django/db/backends/base/base.py&quot; in connect
    118.         conn_params = self.get_connection_params()
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/sqlany_django/base.py&quot; in get_connection_params
    517.         root = Database.Root('PYTHON')
  File &quot;/home/pd/sibp/env/lib/python3.6/site-packages/sqlanydb.py&quot; 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?
  </code></pre>
  <p>How can I fix it?</p>