DEV Community

Nile Lazarus
Nile Lazarus

Posted on

A Guide to Setting Up Pgadmin for Development on Windows(Updated)

In my last guide on this topic, some instructions may not have worked for everyone who attempted it.
This time around, the issues with my last guide have been resolved and thoroughly tested to see if they work for anyone and everyone wanting to configure pgadmin 4 for development on a Windows system.

Install prerequisites

First and foremost, please ensure that you have all of the following requirements fulfilled for your system.

git (https://git-scm.com/downloads)
Node.js 16 and above (https://nodejs.org/en/download)
yarn (https://classic.yarnpkg.com/lang/en/docs/install)
Python 3.7 and above (https://www.python.org/downloads/)
PostgreSQL server (https://www.postgresql.org/download)

Steps

  1. 1. Open a terminal of your choice, I will be using gitbash.
  2. Create a directory for your setup and navigate to the directory
mkdir pgadmin
cd pgadmin
Enter fullscreen mode Exit fullscreen mode
  1. Clone the pgadmin 4 git repository
git clone https://github.com/pgadmin-org/pgadmin4.git
Enter fullscreen mode Exit fullscreen mode

You can now begin building the runtime for your frontend

  1. Navigate to /pgadmin4/runtime directory (while in the pgadmin directory created above)
cd pgadmin4/runtime
Enter fullscreen mode Exit fullscreen mode
  1. Run the following command and copy the contents of the dev_config.json.in file
cat dev_config.json.in
Enter fullscreen mode Exit fullscreen mode

The contents will look something like this:

{
    "pythonPath": "C:/Python38/python.exe",
    "pgadminFile": "../web/pgAdmin4.py"
}
Enter fullscreen mode Exit fullscreen mode

Replace the string stored in pythonPath with the actual path to python.exe stored on your system.

  1. Now run this command to create a new file called dev_config.json and open it for file writing
cat > dev_config.json
Enter fullscreen mode Exit fullscreen mode

A blank line will appear when you enter this command. Paste the contents of the file copied earlier and hit CTRL + D

  1. Run the command
yarn install
Enter fullscreen mode Exit fullscreen mode
  1. Execute the runtime by running this command
node_modules/nw/nwjs/nw
Enter fullscreen mode Exit fullscreen mode

We can now configure the Python environment for the backend

  1. Navigate out of the runtime directory
cd ..
Enter fullscreen mode Exit fullscreen mode
  1. Create a virtual environment using whatever name you wish. I named my environment pgenv
python -m virtualenv pgenv
Enter fullscreen mode Exit fullscreen mode
  1. Activate the environment
source pgenv/Scripts/activate
Enter fullscreen mode Exit fullscreen mode
  1. Upgrade to the latest version of pip
pip install --upgrade pip
Enter fullscreen mode Exit fullscreen mode
  1. Add the path to your PostgreSQL installation bin directory to your environment variables with this command
export PATH="$PATH:/c/Program Files/PostgreSQL/13/bin"
Enter fullscreen mode Exit fullscreen mode

I'm using PostgreSQL v13 but you can change the path to match the version you have installed.

  1. Install dependencies
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode
  1. Open up a second terminal and navigate to the web directory. Then run the following command:
yarn run webpacker --watch
Enter fullscreen mode Exit fullscreen mode
  1. In the first terminal, navigate to the web directory again. Ensure that your virtual environment has been activated and start the server by running
python pgAdmin.py
Enter fullscreen mode Exit fullscreen mode

You will get a message like Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your browser.. Navigate to http://127.0.0.1:5050 in your browser.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay