0

I have a fully updated PyCharm editor (version PyCharm 2022.1.2).

I'm suffering from an SQL query (SQLite3), which is not supported below SQLite version 3.33, and PyCharm seems having version 3.31 only.

I tried my best to upgrade it, and my Ubuntu 20.04 has the most updated version of sqlite3 (3.38), but still, PyCharm doesn't care about it and it still uses the old 3.31 from I have no idea where.

So, how can I update SQLite to a more sane version in PyCharm?

PyCharm uses SQLAlchemy to manipulate the databases, and it is in the latest version (1.4.37), but it still uses SQLite version 3.31.

Project interpreter is a venv'd Python3.8.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
Daniel
  • 2,318
  • 2
  • 22
  • 53
  • related: https://stackoverflow.com/q/49920444/2144390 – Gord Thompson Jun 01 '22 at 20:24
  • 1
    Thx. On command line, `python3` uses the correct version of SQLite (v3.8). However within PyCharm, it still doesn't. So, the question is not about *updating sqlite in python*, but rather *updating sqlite in pycharm*. – Daniel Jun 01 '22 at 20:41
  • Compare the Python version reported when you run `python` in the Terminal tab from within PyCharm vs. when you run `python3` from a regular Ubuntu terminal window. Are they the same? – Gord Thompson Jun 01 '22 at 21:18
  • Yes, they are the same (v3.8) – Daniel Jun 02 '22 at 06:17
  • If you are running from a Configuration check that the correct Python interpreter is selected. See this [screenshot](https://www.jetbrains.com/help/pycharm/run-debug-configuration.html#createExplicitly). – pjcunningham Jun 02 '22 at 09:32
  • Project default is Python3.8 :) – Daniel Jun 02 '22 at 09:44
  • "Yes, they are the same (v3.8)" - Yes, they're both 3.8, but I was thinking that one might be 3.8.x while the other was 3.8.y. – Gord Thompson Jun 02 '22 at 13:09
  • On system I see 3.8.10, whereas in PyCharm I only see python3.8 – Daniel Jun 02 '22 at 15:24

1 Answers1

-1

Simply having the latest version of SQLite installed (e.g., from here) is not enough to get Python on Ubuntu to recognize it.

$ sqlite3 --version
3.38.5 2022-05-06 15:25:27 78d9c993d404cdfaa7fdd2973fa1052e3da9f66215cff9c5540ebe55c407d9fe
$ python3
Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.31.1'

As mentioned in the related question, we need to add /usr/local/lib to the LD_LIBRARY_PATH environment variable:

$ LD_LIBRARY_PATH=/usr/local/lib python3
Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.38.5'

If you don't want to make a global change to LD_LIBRARY_PATH you can add it to your PyCharm run configuration:

PyCharm run configuration

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418