SQLAlchemy: table version already exists. pgAdmin4 fails on Linux Mint 20 and 20.1
0
votes
2
answers
1569
views
*I already found the solution, I just want to share it in case someone has the same problem.*
### Situation ###
Install pgAdmin4 version 4.30 on Linux Mint 20 (Ulyana) and Linux Mint 20.1 (Ulyssa) inside virtualenv. The bulk of pgAdmin4 is a Python web application written using the Flask framework. Therefore, it is an ideal candidate to be implemented in a Python virtualenv as indicated in:
[How to Install PostgreSQL with pgAdmin4 on Linux Mint 20](https://www.tecmint.com/install-postgresql-with-pgadmin4-on-linux-mint/)
And,
[Installing pgAdmin 4 on Linux Mint 20 (ulyana)](https://medium.com/@ogunyemijeremiah/installing-pgadmin-4-on-linux-mint-20-ulyana-741b941479c9)
And in Spanish,
[Cómo instalar PostgreSQL con pgAdmin4 en Linux Mint 20](https://es.linux-console.net/?p=2457)
### Error ###
After finishing the process, when trying to run pgAdmin4 for the **first time**, the following error appears:
Traceback (most recent call last):
File "venv/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 87, in
exec(open(file_quote(setup_py), 'r').read())
File "", line 449, in
File "", line 372, in setup_db
[...]
File "/home/mint/pgAdmin4/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 575, in get_options
self._sa.apply_driver_hacks(self._app, sa_url, options)
File "/home/mint/pgAdmin4/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 908, in apply_driver_hacks
sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute
In the **second attempt** to execute pgAdmin4 the error shown is:
Traceback (most recent call last):
File "/home/mint/pgAdmin4/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_context
self.dialect.do_execute(
File "/home/mint/pgAdmin4/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 681, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: table version already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "venv/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 94, in
app = create_app()
[...]
File "/home/mint/pgAdmin4/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 681, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table version already exists
[SQL:
CREATE TABLE version (
name VARCHAR(32) NOT NULL,
value INTEGER NOT NULL,
PRIMARY KEY (name)
)
]
(Background on this error at: http://sqlalche.me/e/14/e3q8)
This situation started to occur in March 2021 and as far as I know, it is identical on both Linux Mint 20 and Linux Mint 20.1.
> Note: a more suitable location to put the virtualenv would have been /opt
, but for multiple tests I opted for /home
from a live USB with Linux Mint 20. Then apply the final changes to my Linux Mint 20.1
Asked by EspiFreelancer
(1 rep)
Mar 19, 2021, 06:54 PM
Last activity: Feb 6, 2025, 01:01 PM
Last activity: Feb 6, 2025, 01:01 PM