1

I try to import a .pbf file into a PostgreSQL table using osm2pgsql in python using the subprocess module.

The command works perfectly in the command-line, but when I try to use it in subprocess it errors out with:

osm2pgsql version 0.92.0 (64 bit id space)

Osm2pgsql failed due to ERROR: Couldn't open style file 'C:/libs/share/osm2pgsql/default.style': No such file or directory

The Command Prompt is:

osm2pgsql -c -l -r pbf -p singapore-d osm -U postgres -H localhost -S D:/default.style D:/malaysia-singapore-brunei-latest.osm.pbf

The Python Code is:

import subprocess

subprocess.call(['osm2pgsql', '-c', '-l', '-r', 'pbf', '-p', 'singapore', '-d', 'osm', '-U', 'postgres', '-H',
             'localhost', '-S', 'D:/default.style','D:/malaysia-singapore-brunei-latest.osm.pbf'],
            shell=True, env={'PATH': 'C:\osm2pgsql'})
  • would you please try using double quotes? – Devils Dream Jul 1 at 5:56

Your Answer

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

Browse other questions tagged or ask your own question.