I have a problem with osm2pgsql when it runs in a qgis plugin. The function i use looks like this:

    osm2pgsql = "osm2pgsql -s -d {databaseName} -U {databaseUser} -H {databaseHost} -E {SRID_GEOMETRY} {osm_file}"\


When i run this function in the python console in QGIS it runs without a problem. But when this function is used in a plugin it doesent't work. The osm2pgsql function starts with the console output

 Using projection SRS 32632 (EPSG:32632)
 Setting up table: planet_osm_point

but then nothing happens and qgis freezes. When I close qgis the function starts running and finishes successfully.

Has anyone an idea why this happens?

  • Osm2pgsql requires a lot of CPU, RAM and temporary disk space. Can you control how much is available for the plugin? And whether it can open temporary files?
    – AndreJ
    Oct 21, 2014 at 7:51
  • The osm file I use has a size of only 10 MB. The strange thing is that if i load it as a script it runs in ~10 sec successfully.
    – Martin
    Oct 21, 2014 at 7:54

1 Answer 1


I just found a solution.

There is also an active psycop2 connection. When I commit it or close the connection before osm2pgsql runs and open it afterwards again it works. Probably osm2pgsql can't access to the database if this connection is open.

  • 1
    That makes sense. osm2pgsql changes/deletes the database tables too. This might be blocked if another connection exists.
    – AndreJ
    Oct 21, 2014 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.