Question Authors' Forum

Error on SQL-Questions: No such file or directory: 'sqlite3'

Error on SQL-Questions: No such file or directory: 'sqlite3'

de Rea Sutter -
Número de respuestas: 2


Last week I've had a look at the sample SQL-questions, and they worked perfectly well.

Since then, we had to go back to an older version of the server. It should be a very similar set-up, but it seems that there is a crucial difference I can't find. Maybe you can help me detect the problem, so I can revert that change?

When I run one of the example SQL-questions, two things happen:

  1. Moodle tells me in a banner at the top of the page that it "Cannot read file 'q1.db'. Either the file does not exist or there is a permission problem".
  2. Validate on Save gives me the following error message in the 'Got'-column:

    Traceback (most recent call last):
      File "__tester__.python3", line 40, in <module>
      File "/usr/lib/python3.5/", line 626, in check_output
      File "/usr/lib/python3.5/", line 693, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/lib/python3.5/", line 947, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.5/", line 1551, in _execute_child
        raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: 'sqlite3'
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "__tester__.python3", line 43, in <module>
        raise Exception("sqlite3 error: " + str(e))
    Exception: sqlite3 error: [Errno 2] No such file or directory: 'sqlite3' 

As for the first question: I found q1.db files in /tmp/jobe_(random chars) files, they have 644-rights for user and group www-data. Is that wrong?

As for the second point: sqlite3 is present in /usr/lib/python3.5/sqlite3.

I followed the advice in another answer to add a print-debug statement to the question template. os.listdir() resolves to this:
['q1.db', 'prog.out', '__pycache__', 'prog.err', '__tester__.python3', 'prog.cmd']
I see that sqlite3 is not present - should it be? how do I get it to be loaded into that directory?

I'd be really grateful for any pointers in the right direction!
En respuesta a Rea Sutter

Re: Error on SQL-Questions: No such file or directory: 'sqlite3'

de Richard Lobb -

The first message (Cannot read file 'q1.db') comes from the Moodle framework, specifically the File Picker. It would normally mean that the file didn't exist (or wasn't readable) on your client machine, so nothing to do with either the Moodle server or the Jobe server. I'm not sure how it came about in your case, though. Presumably it came about while you were editing the question author form? If you were able to go ahead and test the question anyway, can I assume you found a workaround? If not, I suggest importing the question again or uploading your own sqlite3 database file as an alternative support file to the existing question.

The sqlite3 missing messages all relate to the Jobe server, which doesn't have the sqlite3 executable installed. The code you found in /usr/lib/python3.5 is the Python library code to interface to an sqlite3 database but isn't relevant here. It sounds like you have switched back to an old Jobe server, built before sqlite3 was one of the default installs. The solution is simply to (re)install it:

sudo apt-get install sqlite3

En respuesta a Richard Lobb

Re: Error on SQL-Questions: No such file or directory: 'sqlite3'

de Rea Sutter -

Thank you, Richard!

Your answer was not only fast and helpful, but also so much friendlier than I'm used to from other forums :·)

Yes, the first problem occurred indeed when editing the questions. I'd previously just ignored it. Apparently the absence of sqlite3 led to an error before the file became relevant.

I've now installed sqlite3, then had to delete and re-import the sample questions, and now everything works perfectly.