Although my application works just fine when running it from my IDE, compiling it presents this error:
sqlite3.OperationalError: unable to open database file
Fatal Python error: PyEval_RestoreThread: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)
Python runtime state: initialized
Current thread 0x0000000104410580 (most recent call first):
<no Python frame>
Extension modules: PIL._imaging (total: 1)
Abort trap: 6
Doing some research, I have not been able to find a solution and I'm sure its something small. I have been able to confine the issue to an initialiser in one of my files since commenting out this section allows the application to compile easily with no more errors:
def __init__(self):
database_path = 'Login.db'
absolute_path = os.path.abspath(database_path)
print(f"Database path: {absolute_path}")
self.conn = sqlite3.connect(absolute_path)
self.cur = self.conn.cursor()
if not os.path.exists("Login.db"):# Create database if it doesn't already exist
self.cur.execute(
"""
CREATE TABLE IF NOT EXISTS Login (
id INTEGER PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL
)
"""
)
self.conn.commit()
self.user: User | None = None
Any insight would be appreciated!