Windows10 64bit. I did a clean Python & GDAL install using the instructions on this site, but then for the latest 3.1.2 GDAL version and Python 3.7.9.
I'm trying to run a most basic gdal2tiles.py from CMD on a georeferenced (EPSG 31370) pdf:
gdal2tiles.py myfile.pdf
I got the error code below. I also tried running from the python IDLE with os.system, which of course returns the same error. I also tried with a georeferenced tiff without succes. I noticed the same error was posted recently on the OSGeo github issues page.
ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db
Traceback (most recent call last):
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\lib\site-packages\osgeo\osr.py", line 933, in __init__
self.this.append(this)
AttributeError: 'SpatialReference' object has no attribute 'this'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\Scripts\gdal2tiles.py", line 2928, in <module>
main()
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\Scripts\gdal2tiles.py", line 2922, in main
single_threaded_tiling(input_file, output_folder, options)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\Scripts\gdal2tiles.py", line 2849, in single_threaded_tiling
conf, tile_details = worker_tile_details(input_file, output_folder, options)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\Scripts\gdal2tiles.py", line 2765, in worker_tile_details
gdal2tiles.open_input()
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\Scripts\gdal2tiles.py", line 1535, in open_input
self.in_srs, self.in_srs_wkt = setup_input_srs(input_dataset, self.options)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\Scripts\gdal2tiles.py", line 737, in setup_input_srs
input_srs = osr.SpatialReference()
File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\lib\site-packages\osgeo\osr.py", line 934, in __init__
except __builtin__.Exception:
NameError: name '__builtin__' is not defined
Any ideas on how to fix this?
/EDIT/ I took a look at python37/lib/osgeo/site-packages/osr.py It says version 2.0.4, whereas on github the latest version is 3.0.12 I tried replacing the source code with this of version 3.0.12 This tiles are created, but throws the error below. The created tiles have the wrong numbering, so the spatialReference is still faulty.
ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db