question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TerminalIPythonApp] ERROR | Failed to open SQLite history

See original GitHub issue

Here’s how the error occurs ; I’m working on a slurm-managed shared cluster:

$ module load anaconda/3
$ source $CONDA_ACTIVATE
$ conda create --name 'clouds' python=3.6.4
[...]
$ conda install ipython
[... no error]
$ which ipython
/network/home/schmidtv/.conda/envs/clouds/bin/ipython # as expected
$ ipython
[TerminalIPythonApp] ERROR | Failed to open SQLite history /network/home/schmidtv/.ipython/profile_default/history.sqlite (disk I/O error).
[TerminalIPythonApp] ERROR | History file was moved to /network/home/schmidtv/.ipython/profile_default/history-corrupt.sqlite and a new file created.
[TerminalIPythonApp] ERROR | Failed to open SQLite history /network/home/schmidtv/.ipython/profile_default/history.sqlite (disk I/O error).
[TerminalIPythonApp] ERROR | History file was moved to /network/home/schmidtv/.ipython/profile_default/history-corrupt.sqlite and a new file created.
[TerminalIPythonApp] ERROR | Failed to open SQLite history /network/home/schmidtv/.ipython/profile_default/history.sqlite (disk I/O error).
[TerminalIPythonApp] ERROR | Failed to load history too many times, history will not be saved.
Python 3.6.4 |Anaconda, Inc.| (default, Mar 13 2018, 01:15:57)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sqlite3

In [2]: sqlite3.sqlite_version
Out[2]: '3.29.0'

In [3]: sqlite3.version
Out[3]: '2.6.0'

In [4]: import IPython

In [5]: print(IPython.sys_info())
{'commit_hash': 'c233c25ab',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/network/home/schmidtv/.conda/envs/clouds/lib/python3.6/site-packages/IPython',
 'ipython_version': '7.8.0',
 'os_name': 'posix',
 'platform': 'Linux-4.15.0-54-generic-x86_64-with-debian-buster-sid',
 'sys_executable': '/network/home/schmidtv/.conda/envs/clouds/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.6.4 |Anaconda, Inc.| (default, Mar 13 2018, 01:15:57) \n'
                '[GCC 7.2.0]'}

I’m aware of #9909 and #11407 but none help as it seems my sqlite dist is up to date

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

9reactions
ashkan-leocommented, Mar 4, 2020

I also face this issue. I’m opening an ipython repl through Emacs. I get the following exceptiosn:

[TerminalIPythonApp] ERROR | Failed to create history session in /Users/ashkanaleali/.ipython/profile_default/history.sqlite. History will not be saved.
Traceback (most recent call last):
  File "/Users/ashkanaleali/w/fantasysports/.direnv/python-venv-3.7.3/lib/python3.7/site-packages/IPython/core/history.py", line 543, in __init__
    self.new_session()
  File "</Users/ashkanaleali/w/fantasysports/.direnv/python-venv-3.7.3/lib/python3.7/site-packages/decorator.py:decorator-gen-22>", line 2, in new_session
  File "/Users/ashkanaleali/w/fantasysports/.direnv/python-venv-3.7.3/lib/python3.7/site-packages/IPython/core/history.py", line 58, in needs_sqlite
    return f(self, *a, **kw)
  File "/Users/ashkanaleali/w/fantasysports/.direnv/python-venv-3.7.3/lib/python3.7/site-packages/IPython/core/history.py", line 570, in new_session
    self.session_number = cur.lastrowid
sqlite3.OperationalError: database is locked
Python 3.7.3 (default, Sep  5 2019, 17:14:41) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

4reactions
liwt31commented, May 29, 2021

This seems to be an issue with the network file system. You can try the following C code to test if the flock system call works normally:

#include <stdio.h>
#include <sys/file.h>

int main(){
    int fd = open("test.db", O_RDWR | O_CREAT);
    fprintf(stderr, "Prepare Locking File: %d\n", fd);
    int res = flock(fd, LOCK_SH);
    fprintf(stderr, "Result: %d\n", res);
}

For me, the system call hangs forever, although it works perfectly fine for local disks.

My solution to the problem is reporting the issue to the cluster manager, who restarted the NFS, and then the problem is solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ipython/ipython/help - Gitter
[IPKernelApp] ERROR | Failed to open SQLite history /root/.ipython/profile_default/history.sqlite (disk I/O error).
Read more >
SQLAlchemy + SQLite Locking in IPython Notebook
OperationalError: database is locked [TerminalIPythonApp] ERROR | Failed to open SQLite history :memory: (database is locked).
Read more >
An error ocurred while starting the kernel - Google Groups
I;m new for Python. Iam using Spyder 4 with Python 3.7. When run the Spyder An error ocurred. An error ocurred while starting...
Read more >
Fixing Jupyter notebook/lab nfs4 errors on the CBS server
[IPKernelApp] ERROR | Failed to open SQLite history /home/ROBARTS/alik/.ipython/profile_default/history.sqlite (disk I/O error).
Read more >
Terminal IPython options — IPython 8.7.0 documentation
lines of code to run at IPython startup. ... set enabled=False to disable the SQLite history, in which case there will be no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found