FS#70918 - [pgadmin4] Do not work since flask-2.0 update
Attached to Project:
Community Packages
Opened by Bastien Durel (bastiendurel) - Monday, 17 May 2021, 14:44 GMT
Last edited by Jelle van der Waa (jelly) - Sunday, 03 September 2023, 15:32 GMT
Opened by Bastien Durel (bastiendurel) - Monday, 17 May 2021, 14:44 GMT
Last edited by Jelle van der Waa (jelly) - Sunday, 03 September 2023, 15:32 GMT
|
Details
Hello.
python-flask had been upgraded to 2.0 on may 12. Since this date, pgadmin4 wsgi server cannot start anymore, as flask API changed. Traceback (most recent call last): File "/usr/lib/pgadmin4/web/pgAdmin4.py", line 94, in <module> app = create_app() File "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 630, in create_app app.register_blueprint(module) File "/usr/lib/python3.9/site-packages/flask/scaffold.py", line 54, in wrapper_func return f(self, *args, **kwargs) File "/usr/lib/python3.9/site-packages/flask/app.py", line 1022, in register_blueprint blueprint.register(self, options) File "/usr/lib/pgadmin4/web/pgadmin/utils/__init__.py", line 66, in register super(PgAdminModule, self).register(app, options, first_registration) TypeError: register() takes 3 positional arguments but 4 were given I've tried to remove the 'first_registration' parameter, but got another error : Traceback (most recent call last): File "/usr/lib/pgadmin4/web/pgAdmin4.py", line 94, in <module> app = create_app() File "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 628, in create_app for module in app.find_submodules('pgadmin'): File "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 79, in find_submodules module = import_module(module_name) File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 855, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/usr/lib/pgadmin4/web/pgadmin/preferences/__init__.py", line 26, in <module> from pgadmin.browser.server_groups import ServerGroupModule as sgm File "/usr/lib/pgadmin4/web/pgadmin/browser/server_groups/__init__.py", line 20, in <module> from pgadmin.browser.utils import NodeView File "/usr/lib/pgadmin4/web/pgadmin/browser/utils.py", line 16, in <module> from flask.views import View, MethodViewType, with_metaclass ImportError: cannot import name 'with_metaclass' from 'flask.views' (/usr/lib/python3.9/site-packages/flask/views.py) As flask version was bumped from 1.1 to 2.0, I expect there may be a lot of API changes, as as I don't know flask (and not many python), I won't be able to dig more |
This task depends upon
Closed by Jelle van der Waa (jelly)
Sunday, 03 September 2023, 15:32 GMT
Reason for closing: Deferred
Additional comments about closing: Package dropped to AUR
Sunday, 03 September 2023, 15:32 GMT
Reason for closing: Deferred
Additional comments about closing: Package dropped to AUR
Download older package versions of python-flask and python-flask-security and then install locally
sudo pacman -U python-flask-security-too-3.3.3-3-any.pkg.tar.zst
sudo pacman -U python-flask-1.1.2-4-any.pkg.tar.zst
I had to refresh the sha512sum's to build the package, but it seems incomplete
```
bastien@data-bastien:~$ pgadmin4
/usr/bin/pgadmin4: ligne 3: /usr/lib/pgadmin4/runtime/pgAdmin4: Aucun fichier ou dossier de ce type
bastien@data-bastien:~$ ls /usr/lib/pgadmin4/
docs web
bastien@data-bastien:~$
```
https://hub.docker.com/r/dpage/pgadmin4/
flask --version
Python 3.6.8
Flask 2.0.1
Werkzeug 2.0.1
The command 'yum list python-flask --showduplicates' does not show any other available versions.
python3 -m venv venv
source venv/bin/activate
pip install pgadmin4
venv/bin/pgadmin4
I use Arch Linux but the same instructions also should work on CentOS and Debian.
I known that official pgadmin4 Debian packages also use virtualenv so that older Flask can be used without interfering with OS packaged Flask version.
https://files.pythonhosted.org/packages/4d/5b/2d145f5fe718b2f15ebe69240538f06faa8bbb76488bf962091db1f7a26d/Flask-1.1.4.tar.gz
File "/usr/lib/pgadmin4/web/pgadmin/about/__init__.py", line 20, in <module>
import httpagentparser
ModuleNotFoundError: No module named 'httpagentparser'
After installing python-httpagentparser, it lacks another module I did not find via a quick search :
File "/usr/lib/pgadmin4/web/pgadmin/about/__init__.py", line 22, in <module>
from user_agents import parse
ModuleNotFoundError: No module named 'user_agents'
https://aur.archlinux.org/packages/python-user-agents/ which requires https://aur.archlinux.org/packages/python-ua-parser/ and https://aur.archlinux.org/packages/python-httpagentparser/
Added the dependencies to both the git and 5.4 versions. Do these versions work for you?
pgadmin4-5.4-1.src.tar.gz (3.3 KiB)
No, they don't :
pgadmin4-5.4-1:
Traceback (most recent call last):
File "/usr/lib/pgadmin4/web/pgAdmin4.py", line 98, in <module>
app = create_app()
File "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 691, in create_app
app.register_blueprint(module)
File "/usr/lib/python3.9/site-packages/flask/scaffold.py", line 56, in wrapper_func
return f(self, *args, **kwargs)
File "/usr/lib/python3.9/site-packages/flask/app.py", line 1030, in register_blueprint
blueprint.register(self, options)
File "/usr/lib/pgadmin4/web/pgadmin/utils/__init__.py", line 69, in register
super(PgAdminModule, self).register(app, options, first_registration)
TypeError: register() takes 3 positional arguments but 4 were given
pgadmin4-5.4.r2.g4e067835c-1:
Traceback (most recent call last):
File "/usr/lib/pgadmin4/web/pgAdmin4.py", line 98, in <module>
app = create_app()
File "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 691, in create_app
app.register_blueprint(module)
File "/usr/lib/python3.9/site-packages/flask/scaffold.py", line 56, in wrapper_func
return f(self, *args, **kwargs)
File "/usr/lib/python3.9/site-packages/flask/app.py", line 1030, in register_blueprint
blueprint.register(self, options)
File "/usr/lib/pgadmin4/web/pgadmin/utils/__init__.py", line 69, in register
super(PgAdminModule, self).register(app, options, first_registration)
TypeError: register() takes 3 positional arguments but 4 were given
Looks like we're back to the first error
pgadmin4
NOTE: Configuring authentication for DESKTOP mode.
2021-06-21 14:22:33,639: ERROR pgadmin: Exception in database migration.
NOTE: Configuring authentication for DESKTOP mode.
2021-06-21 14:22:34,270: ERROR pgadmin: Database migration failed
2021-06-21 14:22:34,272: ERROR pgadmin: Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
self.dialect.do_execute(
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 608, 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 "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 379, in upgrade_db
db_upgrade(app)
File "/usr/lib/pgadmin4/web/pgadmin/setup/db_upgrade.py", line 25, in db_upgrade
flask_migrate.upgrade(migration_folder)
File "/usr/lib/python3.9/site-packages/flask_migrate/__init__.py", line 92, in wrapped
f(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/flask_migrate/__init__.py", line 162, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/usr/lib/python3.9/site-packages/alembic/command.py", line 294, in upgrade
script.run_env()
File "/usr/lib/python3.9/site-packages/alembic/script/base.py", line 490, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 97, in load_python_file
module = load_module_py(module_id, path)
File "/usr/lib/python3.9/site-packages/alembic/util/compat.py", line 182, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/lib/pgadmin4/web/pgadmin/setup/../../migrations/env.py", line 93, in <module>
run_migrations_online()
File "/usr/lib/pgadmin4/web/pgadmin/setup/../../migrations/env.py", line 86, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/usr/lib/python3.9/site-packages/alembic/runtime/environment.py", line 813, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/lib/python3.9/site-packages/alembic/runtime/migration.py", line 561, in run_migrations
step.migration_fn(**kw)
File "/usr/lib/pgadmin4/web/migrations/versions/fdc58d9bd449_.py", line 45, in upgrade
op.create_table('version',
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/usr/lib/python3.9/site-packages/alembic/operations/ops.py", line 1072, in create_table
return operations.invoke(op)
File "/usr/lib/python3.9/site-packages/alembic/operations/base.py", line 354, in invoke
return fn(self, operation)
File "/usr/lib/python3.9/site-packages/alembic/operations/toimpl.py", line 101, in create_table
operations.impl.create_table(table)
File "/usr/lib/python3.9/site-packages/alembic/ddl/impl.py", line 277, in create_table
self._exec(schema.CreateTable(table))
File "/usr/lib/python3.9/site-packages/alembic/ddl/impl.py", line 146, in _exec
return conn.execute(construct, multiparams)
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
return meth(self, multiparams, params)
File "/usr/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 72, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1068, in _execute_ddl
ret = self._execute_context(
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1316, in _execute_context
self._handle_dbapi_exception(
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception
util.raise_(
File "/usr/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
self.dialect.do_execute(
File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 608, 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/13/e3q8)
....
cut repeating fault output off here
It appears it creates the table, then there is some error before it can populate it, it then tries to create the table again.
...
Does anyone have any idea if upstream is tracking this topic?
5.4 dropped all C code along with other layout changes which meant a lot of changes to the PKGBUILD.
As users installing with PIP were not having issues, I was inclined to believe it was still a packaging issue.
Upstream seems to have handled the flask-security-too-4 issue, but not the flask-2 one.
```
'psycopg2.extensions.Column' object has no attribute '_asdict'
```
when attempting to connect to a database.
Downgrading to 2.8.6-4 fixes the problem.
It really is a shame the upstream bugtracker cannot be anonymously viewed...
https://stackoverflow.com/questions/67610220/pgadmin4-error-modulenotfounderror-no-module-named-email-validator
You can run pgadmin4 via docker, and link it directly to the host network.
docker run -e 'PGADMIN_LISTEN_PORT=8080' \
-e 'PGADMIN_DEFAULT_EMAIL=user@domain.com' \
-e "PGADMIN_DEFAULT_PASSWORD=secret" \
--network="host" \
dpage/pgadmin4:latest
Then visit http://localhost:8080, login with user@domain.com:secret. You can now add servers like you might normally, just specify "localhost" as the host and your normal username (I think that's how arch configures access by default).
I think that was released with pgAdmin4 6.3.
Maybe updating the Arch packages to the latest (6.11 or perhaps 6.12) is a good fix for this problem.
the issue itself "pgadmin4 is not starting" still exists (16.05.2023).
On a fresh installed arch linux with a fresh installed pgadmin4, all I see is a Window with "Starting pgAdmin4 server..."
From the command line, I see the following lines of code
```bash
QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
Semaphore name: "pgadmin4-<string: username>-<string: lots_of_characters>-sema"
Shared memory segment name: "pgadmin4-sl90fyqo-a59283b86ae8ae85d20fdf770d799dd7-shmem"
Python path: "/usr/lib/python3.11:/usr/lib/python3.11/lib-dynload:/usr/lib/python3.11/site-packages"
Python Home: "/usr/lib/python3.11"
Webapp path: "/usr/lib/pgadmin4/web/pgAdmin4.py"
```
After reading the comment section, this seams to be a longer issue. As a user, it is not satisfying to install a software that is not working.
So my best idea is to:
* Either update the package again and keep fingers crossed all is working
* Update the wiki section to either use a docker container or pip (maybe I will do that this week to guide other peoples to alternatives :-))
* Remove this package from the shoulders of the maintainer (he really has enough other areas to take care of)
Please, don't think my comment has any intention of spreading anger or frustration.
Best regards and thanks for the maintenance effort so far.