pgadmin4 is running perfectly before the system update of ubuntu 16.04 I didn't actually check what are those updates.
But after the update and I tried running pgAdmin, it boots up and shows the pgAdmin loading screen. Then it loads for a long while and eventually gives me the error:
The application server could not be contacted.
I checked the pgAdmin4 logs and it gives me:
AttributeError: 'Request' object has no attribute 'is_json'
2020-05-18 16:08:46,684: ERROR pgadmin: 'Request' object has no attribute 'is_json'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 1473, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1666, in preprocess_request
rv = func()
File "/usr/lib/python3/dist-packages/flask_principal.py", line 477, in _on_before_request
identity = loader()
File "/usr/lib/python3/dist-packages/flask_security/core.py", line 515, in _identity_loader
if not isinstance(current_user._get_current_object(), AnonymousUserMixin):
File "/usr/lib/python3/dist-packages/werkzeug/local.py", line 307, in _get_current_object
return self.__local()
File "/usr/lib/python3/dist-packages/flask_login/utils.py", line 26, in <lambda>
current_user = LocalProxy(lambda: _get_user())
File "/usr/lib/python3/dist-packages/flask_login/utils.py", line 302, in _get_user
current_app.login_manager._load_user()
File "/usr/lib/python3/dist-packages/flask_login/login_manager.py", line 313, in _load_user
return self._load_from_request(request)
File "/usr/lib/python3/dist-packages/flask_login/login_manager.py", line 370, in _load_from_request
user = self.request_callback(request)
File "/usr/lib/python3/dist-packages/flask_security/core.py", line 475, in _request_loader
if request.is_json:
File "/usr/lib/python3/dist-packages/werkzeug/local.py", line 348, in __getattr__
return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'is_json'
I already tried searching for it, but I am not a python guy. My guess is python version incompatibility. I saw a previous question about this 4 days ago. And it was deleted. I am not sure why.
Note: There is no config changes or anything.
EDIT (thanks to @Des Magner comment): This bug is already being tracked by PostgreSQL team https://redmine.postgresql.org/issues/5565
Got the same problem.
My solution is not the best and easiest but it works.
I create new virtual env with python 3.8 and try to run PgAdmin. Ofcourse it failures because of unavailable python modules. So I install module and run PgAdmin from terminal (like this "python3 /usr/share/pgadmin4/web/pgAdmin4.py") again then again and again...
Until I face the problem with import
ImportError: cannot import name 'default_render_json' from 'flask_security.views'
The solution is here and it is pretty simple https://forums.opensuse.org/showthread.php/539523-pgAdmin4-startet-nicht-mehr?s=75392d29ead60bd332ff6f2541467dba&p=2930160#post2930160
Also you have to install libpq to compile psycopg2
In summary my steps are:
pip freeze output is:
Install the latest pgAdmin4 version (4.22) using their python-wheel installer (Requires python 3.4+) as workaround while they fix this bug.
I used miniconda for creating a virtual environment in python 3.7.
Once I created and activated the virtual environment I:
Created the folders "/var/lib/pgadmin" and "/var/log/pgadmin" and set up proper writing permissions for the user running the web server (apache or the user launching the "desktop" version).
Make sure pip is installed in your environment:
Downloaded the latest wheel file and installed it using pip:
Upgraded pyasn1 to version 0.4.8:
and for upgrading to the latest version:
Ran the following command and followed the instructions to set up the admin account for pgAdmin4 web server:
or
For starting pgAdmin4 each time, you have to activate your conda environment first and then run the command "pgAdmin4" or "pgadmin4".
If you need the WSGI configuration file, you can find it at [/miniconda/installation/path]/lib/python3.X/site-packages/pgadmin4/ or at [/miniconda/installation/path]/envs/[your_virtualenv_name]/lib/python3.X/site-packages/pgadmin4/.
To deploy a WSGI server for pgAdmin4 please check this document.
Finally, if you want to use different paths to "/var/lib/pgadmin" and "/var/log/pgadmin":
Create a
config_local.py
file alongside the existingconfig.py
file. You can find it at the same directory where the WSGI configuration file is.Edit
config_local.py
and add the following settings. In most cases, the default file locations should be appropriate: