I rebuilt this several times, with various users, the most recent being:
sudo python3.7 -m venv --clear --system-site-packages --symlinks /opt/python_venv/3.7/pgadmin4/.
I also installed all the FreeBSD py37 packages for modules referenced in the traceback that I could identify:
Code:
pkg install py37-cryptography \
py37-ndg_httpsclient \
py37-openssl \
py37-paramiko \
py37-pyasn1 \
py37-sshtunnel
I discovered that despite installing the
py37-cryptography package,
pip outside the venv could not find it. The effect this had when building
pgadmin4 inside the venv was that cryptography v3.0 was built and used by the venv
pip instead of the FreeBSD packaged v2.6.1 in local.
Therein lay the problem. I deleted the
venv and reinstalled
py37-cryptography using the
-f option to
pkg install and
pip could now find the local site cryptography module from inside the venv.
Following this and recreating the
venv building
pgadmin4 inside it produced a working
pgadmin4 server.
This is solved.
P.S.
There is no desktop application provided for FreeBSD. Those are wrappers for various GDMs which set the virtual environment and call
pgadmin4, presumably after setting the
SERVER_MODE env variable to False. There is probably one for
mate but I did not bother to look.
To use
pgadmin4 one must enter the virtual environment:
Code:
[toor@vhost01 ~ (master)]# source /opt/python_venv/3.7/pgadmin4/bin/activate
(pgadmin4) [toor@vhost01 ~ (master)]# /opt/python_venv/3.7/pgadmin4/bin/pgadmin4
<ctrl C>
(pgadmin4) [toor@vhost01 ~ (master)]# deactivate
[toor@vhost01 ~ (master)]#
If run directly with the default config.py file then the
pgadmin4 server will start, and you can connect to localhost:5050, but you will get an invalid CSRF token error at logon. The cause of this is unknown to me and likely to remain that way. I have no intention of running this as a public service.
To avoid this error configure PGAdmin4 as a desktop browser application by setting SERVER_MODE = False in
config_local.py:
Code:
# replace /opt/python_venv/3.7/pgadmin4/ with whatever you named your venv virtual environment location.
cp -p /opt/python_venv/3.7/pgadmin4/lib/python3.7/site-packages/pgadmin4/config.py \
/opt/python_venv/3.7/pgadmin4/lib/python3.7/site-packages/pgadmin4/config_local.py
gvim cp /opt/python_venv/3.7/pgadmin4/lib/python3.7/site-packages/pgadmin4/config.py /opt/python_venv/3.7/pgadmin4/lib/python3.7/site-packages/pgadmin4/config_local.py
. . .
if (not hasattr(builtins, 'SERVER_MODE')) or builtins.SERVER_MODE is None:
SERVER_MODE = True
else:
SERVER_MODE = builtins.SERVER_MODE
# Enable desktop mode. Must follow default setting above.
SERVER_MODE = False
. . .
In server mode the default location for the sqlite3 password database is:
/var/lib/pgadmin/pgadmin4.db. In desktop mode the default location is
~/.pgadmin/pgadmin4.db.
Even in desktop mode you will be asked for a master username and password. Do not forget them. PGAdmin4 is configured to listen on localhost as a default. Therefor a strong master password is only required on multi-user systems. Which in my environment is a vanishing small number approaching zero.