ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db when using Pyinstaller

9.2k views Asked by At

I have found some issues opened about this error but I cannot find a solution that works for me.

I am getting errors related to proj.db when running an executable file I have created using pyinstaller.

I have Windows 10, Python 3.5 and I have in my environment pyproj 2.4.2 and gdal 3.0.4

I am using GDAL in a python script and I have an environment that it is working fine for me when I test the script using Pycharm. So my pycharm interpreter is pointing to that environment with python 3.5, pyproj 2.4.2 and gdal 3.0.4 and the script runs with no issues.

However, when I build a standalone script using pyinstaller, the script raises the next error:

`ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db`
`PROJ: proj_identify: Cannot find proj.db`
`Failed to auto identify EPSG: 7`
`PROJ: proj_identify: Cannot find proj.db`
`Failed to auto identify EPSG: 7`

So I have tried to set in my script the path to proj library in different ways:

os.environ['GDAL_DATA'] = r'C:\Program Files\QGIS 3.4\share\gdal'
os.environ['PROJ_LIB'] = r'C:\Program Files\QGIS 3.4\share\proj'
os.environ['PROJ_LIB'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'proj.db')

And then run again pyinstaller, but it does not work.

Moreover, I have tried to add the option "-p 'path_to_osgeo'" to my pyinstaller command, but it has no action.

I am not sure where the script takes the proj.db, if it is coming from the virtual environment or it comes from the environmental variables in the computer. I don't know how can I tell then to pyinstaller or how can I add to my script the correct path to proj.db so when I build the executable I don't get this error anymore.

I don't know why the script works when I run it using pycharm but it does not work when I create an executable file.

Any suggestions?

Thank you

0

There are 0 answers