Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ImportError: cannot import name 'ImmutableDict'" error when installing pgAdmin4

I am trying to install pgAdmin4 on Ubuntu 18.04 with python3 following this tutorial (https://www.digitalocean.com/community/tutorials/how-to-install-configure-pgadmin4-server-mode) but when configuring pgAdmin4 I get this error:

(my_env) 1 jess@hilarioserver:~/environments$ python my_env/lib/python3.6/site-packages/pgadmin4/setup.py
Traceback (most recent call last):
  File "my_env/lib/python3.6/site-packages/pgadmin4/setup.py", line 17, in <module>
    from pgadmin.model import db, User, Version, ServerGroup, Server, \
  File "/home/cta/environments/my_env/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 21, in <module>
    from flask_babelex import Babel, gettext
  File "/home/cta/environments/my_env/lib/python3.6/site-packages/flask_babelex/__init__.py", line 23, in <module>
    from werkzeug import ImmutableDict
ImportError: cannot import name 'ImmutableDict'

I already tried to install werkzeug but still giving the same error.

alembic (1.4.0) Babel (2.8.0) bcrypt (3.1.7) blinker (1.4) cffi (1.13.2) Click (7.0) cryptography (2.8) Flask (1.0.2) Flask-BabelEx (0.9.3) Flask-Compress (1.4.0) Flask-Gravatar (0.5.0) Flask-Login (0.4.1) Flask-Mail (0.9.1) Flask-Migrate (2.4.0) Flask-Paranoid (0.2.0) Flask-Principal (0.4.0) Flask-Security (3.0.0) Flask-SQLAlchemy (2.3.2) Flask-WTF (0.14.2) itsdangerous (1.1.0) Jinja2 (2.11.1) Mako (1.1.1) MarkupSafe (1.1.1) paramiko (2.7.1) passlib (1.7.1) pgadmin4 (4.18) pip (9.0.1) pkg-resources (0.0.0) psutil (5.5.1) psycopg2-binary (2.8.4) pycparser (2.19) PyNaCl (1.3.0) python-dateutil (2.8.1) python-editor (1.0.4) pytz (2018.9) setuptools (39.0.1) simplejson (3.16.0) six (1.14.0) speaklater (1.3) SQLAlchemy (1.3.13) sqlparse (0.2.4) sshtunnel (0.1.5) Werkzeug (1.0.0) wheel (0.34.2) WTForms (2.2.1)

Any idea?

like image 476
Jesús Magallón Avatar asked Feb 07 '20 03:02

Jesús Magallón


3 Answers

I've been troubleshooting this today while installing another package as well and it seems there was a new version released today that might be causing the issue.

https://pypi.org/project/Werkzeug/#history

I decided to go back to an earlier version (0.16.1) and it solved my issue. To downgrade:

pip install --upgrade werkzeug==0.16.1

Hope this works for you as well.

like image 91
Dee Avatar answered Oct 17 '22 23:10

Dee


The method of import has changed for v1.0.0. See this warning message:

The import 'werkzeug.ImmutableDict' is deprecated and will be removed in Werkzeug 1.0. Use 'from werkzeug.datastructures import ImmutableDict' instead.
    from werkzeug import ImmutableDict
like image 6
fraxture Avatar answered Oct 17 '22 22:10

fraxture


upgrade to flask-babelex>=0.9.4 (or flask-babel>=1.0.0 for other projects) if other dependencies will allow it. flask-babelex Github issue 21 flask-babel Github issue 162

like image 2
stuartz Avatar answered Oct 17 '22 21:10

stuartz