0

First off, this is my first post so if my formatting, etiquette, etc. is off please let me know so I can correct it.

Second after an exhaustive google search I have not found a solution.

I am trying to troubleshoot a Python script. It is suppose to run in Python 3.6 and/or newer. I have tried different ways of trying to get it to run i.e. virtual environment, different Python versions (3.6 and 3.8 only), and different users, but it always fails with the same error below. I have checked the installed Python modules that should be the right ones, but am not convinced they may be the right ones needed.

Here is the script (sanitized of course):

import logging

from logstash_async.handler import AsynchronousLogstashHandler

host = 'serverA.xyz.com'
port = 3306

# Get you a test logger
test_logger = logging.getLogger('python-logstash-logger')

# Set it to whatever level you want - default will be info
test_logger.setLevel(logging.DEBUG)

# Create a handler for it
test_logger.addHandler(AsynchronousLogstashHandler(host, port, database_path=None))

# Add the handler to the logger
#test_logger.addHandler(handler)

# sending amessage
test_logger.info("This is a test Message")

This is the error I keep getting:

Traceback (most recent call last):
  File "test_elk.py", line 3, in <module>
    from logstash_async.handler import AsynchronousLogstashHandler
  File "/opt/gpi-datalake/.local/lib/python3.8/site-packages/logstash_async/handler.py", line 11, in <module>
    from logstash_async.worker import LogProcessingWorker
  File "/opt/gpi-datalake/.local/lib/python3.8/site-packages/logstash_async/worker.py", line 17, in <module>
    from logstash_async.database import DatabaseCache, DatabaseLockedError
  File "/opt/gpi-datalake/.local/lib/python3.8/site-packages/logstash_async/database.py", line 7, in <module>
    import sqlite3
ModuleNotFoundError: No module named 'sqlite3'

Modules required (based on exhaustive search):

Python versions tried (including Python virtual environments):

  • Python 3.8.7
  • Python 3.6.8

Environment:

  • Red Hat Enterprise Linux Server release 7.9 (Maipo)

SQLite3 packages installed:

libsqlite3x.x86_64                 20071018-20.el7         @epel                
libsqlite3x-devel.x86_64           20071018-20.el7         @epel                
python-sqlite3dbm.noarch           0.1.4-6.el7             @epel                
sqlite.x86_64                      3.7.17-8.el7_7.1        @rhel-x86_64-server-7
sqlite-devel.x86_64                3.7.17-8.el7_7.1        @rhel-7-server-rpms 

Thanks in advance.

leandrojmp
  • 7,082
  • 2
  • 19
  • 24

1 Answers1

0

You should have the sqlite3 module by default. It seems possible that you have uninstalled it.

Do you see sqlite3 if you type this from an interpreter line?

>>> help("modules")
ekrall
  • 192
  • 8
  • It is not listed. Pysqlite3 is listed. From what I can find in Python3 sqlite was replaced with pysqlite. It is very possible that I removed sqlite3 that was installed. If that is the case and I can only install pysqlite3 in Python3, how would I resolve this conflict? – unsupervised Dec 22 '21 at 18:11
  • sqlite3 is included in the standard Python libraries. so if it is not there by default, you need to reinstall it (that could involve rebuilding Python). https://stackoverflow.com/questions/19530974/how-can-i-add-the-sqlite3-module-to-python – ekrall Dec 23 '21 at 02:09
  • That's what I figured. Thank you. – unsupervised Dec 23 '21 at 03:21