Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pgAdmin4 error: ModuleNotFoundError: No module named 'email_validator'

I'm trying to install pgadmin4 on Arch Linux. Here is what I did:

sudo pacman -S pgadmin4

Then I simply tried running pgadmin4 and got the following error:

"An error occurred initialising the pgAdmin 4 server:\n\nFailed to launch the application server, server thread exiting."

Then, I tried running pgAdmin4.py directly:

sudo python3 /usr/lib/pgadmin4/web/pgAdmin4.py

And I got an error with the following stacktrace:

Traceback (most recent call last):
  File "/usr/lib/pgadmin4/web/pgAdmin4.py", line 35, in <module>
    import config
  File "/usr/lib/pgadmin4/web/config.py", line 25, in <module>
    from pgadmin.utils import env, IS_WIN, fs_short_path
  File "/usr/lib/pgadmin4/web/pgadmin/__init__.py", line 28, in <module>
    from flask_security import Security, SQLAlchemyUserDatastore, current_user
  File "/usr/lib/python3.9/site-packages/flask_security/__init__.py", line 15, in <module>
    from .core import Security, RoleMixin, UserMixin, AnonymousUser, current_user
  File "/usr/lib/python3.9/site-packages/flask_security/core.py", line 48, in <module>
    from .mail_util import MailUtil
  File "/usr/lib/python3.9/site-packages/flask_security/mail_util.py", line 14, in <module>
    import email_validator
ModuleNotFoundError: No module named 'email_validator'

I then tried to install pip in an attempt to install the missing module myself:

sudo pacman -S python-pip

Then:

pip install email_validator

However, the error remains. Should I modify my PATH variable? What am I doing wrong?

EDIT

So, after some help from the comments, and some more searching, I modified the ~/.config/pgadmin/pgadmin4.conf file to have the following PythonPath=/usr/lib/python3.9/site-packages:/usr/lib/python3.9:/home/ddimitrov/.local/lib/python3.9/site-packages, which "resolved" this error but I was greeted with a brand new 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 347, in create_app
    if not os.path.exists(SQLITE_PATH) or get_version() == -1:
  File "/usr/lib/pgadmin4/web/pgadmin/setup/db_version.py", line 19, in get_version
    return version.value
AttributeError: 'NoneType' object has no attribute 'value'

I tried since to reinstall pgadmin4 multiple times, same issue. Any help would be much appreciated.

like image 466
Dimitar Dimitrov Avatar asked Mar 01 '23 14:03

Dimitar Dimitrov


1 Answers

This doesn't fix the specific issue, but it's too long to comment, but it will get you working:

You can run pgadmin4 via docker, and link it directly to the host network.

docker run -e 'PGADMIN_LISTEN_PORT=8080' \
           -e '[email protected]' \
           -e "PGADMIN_DEFAULT_PASSWORD=secret" \
           --network="host" \
           dpage/pgadmin4:latest

Then visit http://localhost:8080, login with [email protected]: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).

See also: https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html#examples

You can also look into configuring pip install pgadmin4 and creating a config.py (perhaps in /etc/pgadmin4?) to set SERVER_MODE=False.

Really wish you could just go pgadmin4 --desktop-mode...

like image 96
markson edwardson Avatar answered Mar 05 '23 14:03

markson edwardson