[GIS] Unable to use pgRouting Layer QGIS plugin with osm2po tool (database connection error)

osm2popgroutingpostgispostgresql

By following these amazing tutorials of Anita Graser An osm2po Quick Start and pgRouting on OSM using osm2po, I was able to use osm2po tool successfully on Windows 7 (x64) with PostgreSQL version 9.5 and pgRouting version 2.1.0. I successfully generated .sql file (at_2po_4pgr.sql), imported the same into my postgres routing DB and then installed QGIS pgRouting Layer plugin through Plugins Manager. Now, I am trying to test pgr_djikstra algorithm using pgRouting Layer plugin but I am running into problem during this last step of the above mentioned tutorial.

I am already connected to my postgres DB through DB Manager of QGIS but in my pgRouting Layer dialogue box, I am never "shown as connected" to my postgres DB as shown in following figure. I tried to press refresh button and drop down list many times but no use.

Screen shot of pgRouting Layer DB connectivity problem

The problem seems to be with database connection through Python. Because, whenever I try to run 'dijkstra' algorithm (just wanted to give it a try anyways) I am getting a Python execution error as shown below. It shows db connection problem in pgRouting python executable file (which is in pgRouting Layer plugin directory). Following are the screen shots of errors I am getting.

Error_screen_shot1

Error_screen_shot2

Although, Python2.7 is the default version and its already added to my system path (in environment variables).

Do I need to modify the indicated python file?

Best Answer

Well, thanks to the previous relevant posts at GIS-SE: pgRouting Layer Plugin Db error and unable to implement pgRouting Layer plugin I figured out my mistake by myself. When I connected to my postgres db through QGIS DB Manager, I did not save username and password which was a mistake and resulted in db connection failure every time.

I have saved username and password and now able to use pgRouting Layer Plugin flawlessly! :)

Related Question