How to Install PostgreSQL with pgAdmin4 on Linux Mint 21/20

pgAdmin is an open-source feature-rich, frontend management tool that allows you to easily administer and manage your PostgreSQL relational database from a web browser.

It provides an easy-to-use user interface that simplifies the creation and monitoring of databases and database objects. PgAdmin 4 is an improvement of the earlier pgAdmin tool and is available for Linux, Windows, macOS systems, and even a Docker container.

In this tutorial, you will learn how to install PostgreSQL with pgAdmin4 on Linux Mint 21 and Linux Mint 20.

Step 1: Install PostgreSQL Database on Linux Mint

1. To start off, launch your terminal and update your packages using the apt package manager as shown.

$ sudo apt update -y

Once the update is complete, proceed to the next step.

Since pgAdmin4 provides a frontend interface for the management of PostgreSQL database objects, it’s essential to have PostgreSQL installed first.

2. To do this, we are going to install the postgresql package and postgresql-contrib which offers extended features that extend the functionality of PostgreSQL.

$ sudo apt install postgresql postgresql-contrib
Install PostgreSQL on Linux Mint
Install PostgreSQL on Linux Mint

3. Usually, PostgreSQL starts automatically on boot up. You can confirm this using the command given below:

$ sudo systemctl status postgresql
Check PostgreSQL Status
Check PostgreSQL Status

4. To log in to your PostgreSQL instance, first switch to the postgres user. The Postgres user comes included by default with the installation of PostgreSQL. Then run the psql command as shown.

$ sudo -i -u postgres
$ psql
# \q
Connect to PostgreSQL Shell
Connect to PostgreSQL Shell

5. Additionally, you can check if the database server is accepting incoming connections as shown.

$ sudo pg_isready
Check PostgreSQL Accepting Incoming Connections
Check PostgreSQL Accepting Incoming Connections

Step 2: Install pgAdmin4 on Linux Mint

pgAdmin4 is available for Ubuntu 16.04 and later versions and can easily be installed using the APT package manager. The same cannot support Linux Mint and Pgadmi4 developers are yet to include support that allows users to easily install the frontend management tool using the APT package manager.

6. The only viable option is to install pgAdmin4 from a virtual environment. So first, we will install the prerequisite packages as shown.

$ sudo apt install libgmp3-dev build-essential libssl-dev
Install Prerequisite Packages
Install Prerequisite Packages

7. Next, install the Python virtual environment and associated dependencies.

$ sudo apt install python3-virtualenv python3-dev libpq-dev
Install Python Virtual Environment
Install Python Virtual Environment

8. Next, create a directory where you will create a virtual environment.

$ mkdir pgadmin4 && cd pgadmin4

9. Then create the virtual environment as shown. Here, pgadmin4env is the name of the virtual environment.

$ virtualenv pgadmin4env
Create Virtual Environment for pgAdmim4
Create Virtual Environment for pgAdmim4

10. Once the virtual environment is in place, activate it as shown.

$ source pgadmin4env/bin/activate

11. Then use the pip tool to install pgadmin4 as shown.

$ pip install
Install PgAdmin4 in Linux Mint
Install PgAdmin4 in Linux Mint

12. Next, create a configuration file

-------- On Linux Mint 20 --------
$ sudo nano pgadmin4env/lib/python3.8/site-packages/pgadmin4/

-------- On Linux Mint 21 --------
$ sudo nano pgadmin4env/lib/python3.10/site-packages/pgadmin4/

and add the lines below.

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')
Create PgAdmin4 Configuration
Create PgAdmin4 Configuration

13. To start the pgAdmin4 management tool, invoke the command:

-------- On Linux Mint 20 -------- 
$ python pgadmin4env/lib/python3.8/site-packages/pgadmin4/

-------- On Linux Mint 21 --------
$ python pgadmin4env/lib/python3.10/site-packages/pgadmin4/
Start PgAdmin4 Service
Start PgAdmin4 Service

14. Finally, head over to your browser and browse the address shown.

You will be prompted to set the master password, so proceed and set a strong password and click the ‘Ok’ button.

Set PgAdmin4 Password
Set PgAdmin4 Password

15. To make things easier, you can create an alias in the ~/.bashrc file as shown.

-------- On Linux Mint 20 -------- 
$ echo "alias startPg='~/pgadmin4/pgadmin4env/bin/python pgadmin4env/lib/python3.8/site-packages/pgadmin4/'" >> ~/.bashrc

-------- On Linux Mint 21 -------- 
$ echo "alias startPg='~/pgadmin4/pgadmin4env/bin/python pgadmin4env/lib/python3.10/site-packages/pgadmin4/'" >> ~/.bashrc

16. Next, update the bashrc file.

$ source ~/.bashrc

17. Finally, you can start the pgAdmin4 management tool by simply invoking the startPg command.

$ startPg &
Start PgAdmin4 Tool
Start PgAdmin4 Tool

Once again head over to your browser and log in to the PgAdmin4 interface. And this concludes the installation of PostgreSQL with pgAdmin4 on Linux Mint 21 and Linux Mint 20.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Winnie Ondara
My name is Winnie, a Linux enthusiast and passionate tech writer in Linux and DevOPs topics. I enjoy keeping abreast with the latest technologies in the Linux ecosystem and trying out new tools provided by the FOSS community.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. Thank you very much. It works fine on my Linux Mint 21. But every time I quit and want to start again I have to go through the following steps to make it start again:

    cd pgadmin4
    source pgadmin4env/bin/activate
    python pgadmin4env/lib/python3.10/site-packages/pgadmin4/

    Otherwise, I get the following error when I run startPg:

    /home/developer/pgadmin4/pgadmin4env/bin/python: can't open file '/home/developer/pgadmin4env/lib/python3.10/site-packages/pgadmin4/': [Errno 2] No such file or directory

    Or when I just try to start

    developer@linuxmint:~$ python pgadmin4env/lib/python3.10/site-packages/pgadmin4/
    Command 'python' not found, did you mean:
      command 'python3' from deb python3
      command 'python' from deb python-is-python3
    • @Developer,

      To simplify the process, you can create a shell script to automate these steps.

      cd /path/to/your/pgadmin4
      source pgadmin4env/bin/activate
      python pgadmin4env/lib/python3.10/site-packages/pgadmin4/

      Make sure to replace /path/to/your/pgadmin4 with the actual path to your pgAdmin4 installation.

      Now make the script executable and start pgAdmin4 by simply running:

      chmod +x

      It looks like your system is suggesting to use python3 instead of python to run the script.

      python3 pgadmin4env/lib/python3.10/site-packages/pgadmin4/

      This should resolve the “Command ‘python’ not found” error. Let me know if you encounter any further issues!

      • Hi Ravi,

        I tried your suggestion on creating a shell script, however I’m not getting anything in return when I run it using chmod +x and ./, it doesn’t start pgadmin tool nor triggers any error in the terminal.

        cd /home/xycmint/pgadmin4
        source pgadmin4env/bin/activate
        python pgadmin4env/lib/python3.10/site-packages/pgadmin4/pgAdmin4.>


  2. Hi, Thanks for the tutorial.

    I am fine with step 12

    If I take the mint 20 option nano says :

    Directory 'pgadmin4env/lib/python3.10/site-packages/pgadmin4' does not exist

    If I take the mint 21 option terminal says:

    python: can't open file '/home/grahamj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/': [Errno 2] No such file or directory

    at which point I remember I am using your install instructions on my LMDE6 install, Can I tweak it for my package base, please?

    • @Graham,

      To fix the error, you need to create the missing directory.

      cd /path/to/your/pgadmin4
      mkdir -p pgadmin4env/lib/python3.10/site-packages/pgadmin4

      After creating the directory, try running the installation steps again.

      To fix “python: can’t open file” error, you need to check your Python version, if it is different than Python 3.8, you need to install or update your Python version.

      After updating the Python version to 3.8, you need to update the path according to your actual directory structure.

      python /home/grahamj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/
  3. Step 11 seems like a dead link

    # pip install

    Please help…

  4. Step 15 in Linux Mint 21 should be:

    $ echo "alias startPg='python pgadmin4env/lib/python3.10/site-packages/pgadmin4/'" >> ~/.bashrc
    • @Frank,

      Here are the instructions to uninstall PostgreSQL with pgAdmin4 on the Linux Mint system.

      $ sudo apt purge postgresql postgresql-contrib
      $ sudo apt purge libgmp3-dev build-essential libssl-dev
      $ sudo apt purge python3-virtualenv python3-dev libpq-dev
      $ rm -rf pgadmin4
      $ pip uninstall pgadmin4
    • @Franco,

      To install PostgreSQL 15 on Linux Mint, then follow these instructions:

      $ sudo apt install curl ca-certificates gnupg
      $ curl | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ >/dev/null
      $ sudo sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
      $ sudo apt update
      $ sudo apt install postgresql-15
  5. Thank you very much brother, I was able to install it up to point 14, the rest was no longer necessary.

    Remember to check the paths of the requests so that pgadmin4 runs.

  6. Hey!

    I’ve followed this guide, but step 13 does not work for some reason. I get this as an error message:

    FileNotFoundError: [Errno 2] No such file or directory: ‘/home/*myname*/pgadmin/*~/.pgadmin’

    What can I do?

  7. FTP server not functioning:

    # pip install
    ERROR: HTTP error 404 while getting
      ERROR: Could not install requirement 
    because of error 404 Client Error: Not Found for url:
    ERROR: Could not install requirement 
    because of HTTP error 404 Client Error: Not Found for url: 
    for URL
  8. Hi,

    I’ve performed as described in this article. Start PgAdmin in the terminal first, then in the browser. And in the browser, I see the empty tree of Servers in the left tab.
    (Installed on Mint 21)

  9. Hey, Guys!

    I had this problem when running explain the analysis.

    Do you have any suggestions?


    :ERROR: unrecognized EXPLAIN option "summary"
    SQL state: 42601

  10. Hi, Thanks for the guide.

    I am stuck on steps 12 and 13 of installing pgadmin. Do I open up a separate terminal tab to add the step 13 command?

      • Hi Ravi,

        Thanks for the reply. I am very new to linux. My confusion is after I copy and paste the code in Step 12 and hit enter, do I open up a new terminal tab to enter the Step 13 instructions? Because after entering the Step 12 instruction, I don’t get a prompt to enter a new instruction.


  11. I am getting the below error while installing pgadmin4 in Linux Mint.

    aceback (most recent call last):
    File "pgadmin4env/lib/python3.8/site-packages/pgadmin4/", line 35, in
    import config
    File "/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/", line 25, in
    from pgadmin.utils import env, IS_WIN, fs_short_path
    File "/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/", line 21, in
    from flask import Flask, abort, request, current_app, session, url_for
    File "/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask/", line 19, in
    from jinja2 import Markup, escape
    ImportError: cannot import name 'Markup' from 'jinja2' (/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/jinja2/

    • @Carlos,

      I have updated the pgadmin4 installation instructions for Linux Mint 21 and Linux Mint 20. I hope it will fix your pgadmin4 installation errors…

  12. As suggested by @Thomas Tschoepke, there’s an easier way: adding the sources to your APT. Linux Mint follows Ubuntu 20, which in turn is based on Debian “bullseye”, so Thomas’s instructions just need to be adjusted:

    $ sudo curl | sudo apt-key add
    $ sudo sh -c 'echo "deb pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list'
    $ sudo apt update
    $ sudo apt install pgadmin4-desktop #for desktop
    $ sudo apt install pgadmin4-web #for web
    If web version:
    $ sudo /usr/pgadmin4/bin/


    • Tried this approach on Linux Mint 20.3 Una (base: Ubuntu 20.04 focal), the installation ran without problems, but starting pgAdmin4 failed with the message “The pgadmin 4 server could not be contacted”.

      Reason in my case:
      the symbolic python-links under /usr/pgadmin4/venv/bin/were dead because of missing python3.9


      $ sudo apt install python3.9
    • Trying this in Mint 21. When I try

      $ sudo /usr/pgadmin4/bin/

      I get

      Setting up pgAdmin 4 in web mode on a Debian-based platform…
      Creating configuration database…
      /usr/pgadmin4/bin/ line 75: /usr/pgadmin4/venv/bin/python3: No such file or directory
      Error setting up server mode. Please examine the output above.

      Looking in /usr/pgadmin4/venv/bin/ the symbolic links to python, python3 and python3.9 are showing as broken.

      I have Python3.10 installed as default. Trying to install 3.9 as well (which I guess is probably a bad idea anyway?) results in

      bio@bio-LIFEBOOK-S752:~$ sudo apt install python3.9
      Reading package lists… Done
      Building dependency tree… Done
      Reading state information… Done
      E: Unable to locate package python3.9
      E: Couldn’t find any package by glob ‘python3.9’

      Any suggestions are gratefully received.


    • $ sudo curl | sudo apt-key add
      $ sudo sh -c 'echo "deb pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
      $ sudo apt update
      $ sudo apt install pgadmin4-desktop #for desktop
      $ sudo apt install pgadmin4-web #for web

      If web version:

      $ sudo /usr/pgadmin4/bin/
      • With these steps I get:

        E: The repository ' pgadmin4 Release' does not have a Release file.
        E: The repository ' ulyssa-pgdg Release' does not have a Release file.

        • Hi Ami,

          If you’re using Linux Mint 20, you just need to change the line:

          deb pgadmin4 main


          deb pgadmin4 main

          in the file “/etc/apt/sources.list.d/pgadmin4.list

          Then continue with the step “sudo apt update”, and so on.


      • Can’t remember the error. But with the steps, I posted above one does not need virtual environments and stuff…

        The install is straight forward as any other package.

  13. pgadmin4env) root@usuario-Intel-powered-classmate-PC:~/pgadmin4# python pgadmin4env/lib/python3.8/site-packages/pgadmin4/
    NOTE: Configuring authentication for DESKTOP mode.
    Traceback (most recent call last):
    File “/root/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/”, line 1771, in _execute_context
    File “/root/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/”, line 717, in do_execute
    cursor.execute(statement, parameters)
    sqlite3.OperationalError: table version already exists

      • Can I ask that want version of python you used, because I got error like this:

        (pgadmin4env) lj@lj-Aspire-V3-471G:~/pgadmin4$ ./pgadmin4env/bin/pgadmin4&
        [1] 38587
        (pgadmin4env) lj@lj-Aspire-V3-471G:~/pgadmin4$ NOTE: Configuring authentication for DESKTOP mode.
        Traceback (most recent call last):
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", 
        line 1705, in _execute_context
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", 
        line 691, 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 "./pgadmin4env/bin/pgadmin4", line 5, in 
            from pgadmin4.pgAdmin4 import main
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/", line 94, in 
            app = create_app()
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/", line 351, in create_app
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/", line 25, in db_upgrade
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask_migrate/", line 95, in wrapped
            f(*args, **kwargs)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask_migrate/", line 280, in upgrade
            command.upgrade(config, revision, sql=sql, tag=tag)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/", line 294, in upgrade
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/script/", line 490, in run_env
            util.load_python_file(self.dir, "")
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/util/", line 97, in load_python_file
            module = load_module_py(module_id, path)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/util/", line 182, in load_module_py
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/", line 93, in 
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/", line 86, in run_migrations_online
          File "", line 8, in run_migrations
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/runtime/", line 813, in run_migrations
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/runtime/", line 560, in run_migrations
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/migrations/versions/", line 45, in upgrade
          File "", line 8, in create_table
          File "", line 3, in create_table
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/", line 1109, in create_table
            return operations.invoke(op)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/", line 354, in invoke
            return fn(self, operation)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/", line 101, in create_table
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/ddl/", line 277, in create_table
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/ddl/", line 146, in _exec
            return conn.execute(construct, multiparams)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1200, in execute
            return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/sql/", line 77, in _execute_on_connection
            return connection._execute_ddl(
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1290, in _execute_ddl
            ret = self._execute_context(
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1748, in _execute_context
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1929, in _handle_dbapi_exception
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/util/", line 211, in raise_
            raise exception
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1705, in _execute_context
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 691, in do_execute
            cursor.execute(statement, parameters)
        sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table version already exists
        CREATE TABLE version (
        	name VARCHAR(32) NOT NULL, 
        	value INTEGER NOT NULL, 
        	PRIMARY KEY (name)
        (Background on this error at:
        [1]+  Exit 1                  ./pgadmin4env/bin/pgadmin4

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.