qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.49k stars 2.99k forks source link

Proj.db not found for GDAL tools on QGIS 3.16 Mac all-in-one installer #39801

Closed spatialthoughts closed 3 years ago

spatialthoughts commented 3 years ago

gdalwarp give an error on QGIS3.16 Mac because it can't find proj.db. Same operation works fine in QGIS3.10 LTR package.

"ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db"

proj_error

To reproduce

  1. Unzip and Load Attached SRTM raster N27E086.hgt.zip 2.Processing -> Toolbox -> Warp (reproject)
  2. Set 'Target CRS' as 'EPSG:32645' and click 'Run'.
  3. Operation fails.

QGIS and OS versions

QGIS version 3.16.0-Hannover QGIS code revision 33475aa559
Compiled against Qt 5.14.2 Running against Qt 5.14.2
Compiled against GDAL/OGR 3.1.2 Running against GDAL/OGR 3.1.2
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.31.1 Running against SQLite 3.31.1
PostgreSQL Client Version 12.3 SpatiaLite Version 4.3.0a
QWT Version 6.1.4 QScintilla2 Version 2.11.4
Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020
OS Version macOS 10.15
Active python plugins ORStools; slyr_community; QuickOSM; ee_plugin; profiletool; DataPlotly; quick_map_services; pathfinder; qdraw; minimal; GeoCoding; pluginbuilder3; show_time; latlontools; Qgis2threejs; qgsAzimuth; plugin_reloader; Mergin; processing; db_manager
gioman commented 3 years ago

Confirmed here too on Catalina.

spatialthoughts commented 3 years ago

@PeterPetrik This is a pretty serious regression and would be good to fix this for the next point release.

PeterPetrik commented 3 years ago

@spatialthoughts . where do you have your application installed? have you relocated it?

spatialthoughts commented 3 years ago

Installed in Applications. Haven't renamed or moved it. Screenshot attached.

qgis
PeterPetrik commented 3 years ago

@spatialthoughts as a workaround, can you please open qgis python console and type

import os
os.environ["PROJ_LIB"]="/Applications/QGIS.app/Contents/Resources/proj"

and retry to run the algorithm?

spatialthoughts commented 3 years ago

Thanks. That Works. Will use the workaround for now. Hopefully, it's an easy fix for the next release.

PeterPetrik commented 3 years ago

i can think of two ways... do you use these algorithms directly (without qgis/processing)? one solution would allow it too, other one will not...

spatialthoughts commented 3 years ago

By directly, you mean running gdalwarp on the command line? I do that occasionally, but if that doesn't work there are ways to install those tools via other means or set an environment variable like here. Making it work via processing toolbox without any workarounds would be the top priority for me.

PeterPetrik commented 3 years ago

because I can either set PROJ_LIB in qgis environment (works only from QGIS) or create a wrapper bash script for every GDAL binary (will work from command line too)

spatialthoughts commented 3 years ago

It would be awesome to get it working properly everywhere. Is it possible to roll out the simple fix (proj_lib in qgis) for 3.16.1 and work towards the global fix for a later release?

PeterPetrik commented 3 years ago

@spatialthoughts can you try in tomorrow's nightly build? should be fixed "correctly" so it should work from command line too

mizraith commented 2 years ago

@spatialthoughts as a workaround, can you please open qgis python console and type

import os
os.environ["PROJ_LIB"]="/Applications/QGIS.app/Contents/Resources/proj"

and retry to run the algorithm?

Just ran into this problem under Monterey and QGIS 3.22.2-Bialowieza Trying to merge about 9 layers. Can confirm that the above appears to work and make the error message go away.

So....this is still an issue a few years later (or it came back)

visaviweb commented 2 years ago

this is still an issue with QGIS 3.24.0-Tisler

Rikuoja commented 2 years ago

Having the same problem with all 3.22 versions, including LTR.

"PROJ_LIB" env variable is not set in QGIS python console. All other GDAL env variables seem to be correctly set.

os.environ
environ({'USER': 'riku', '__CFBundleIdentifier': 'org.qgis.qgis3', 'COMMAND_MODE': 'unix2003', 'LOGNAME': 'riku', 'PATH': '/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/Applications/QGIS-LTR.app/Contents/MacOS/bin:/usr/bin:/bin:/usr/sbin:/sbin', 'PYQGIS_STARTUP': 'pyqgis-startup.py', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.ukED6bKMHa/Listeners', 'SHELL': '/bin/zsh', 'HOME': '/Users/riku', 'QT_AUTO_SCREEN_SCALE_FACTOR': '1', '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x11', 'TMPDIR': '/var/folders/z6/ld52r6fn1dv_1h70k7z7d9n40000gn/T/', 'XPC_SERVICE_NAME': 'application.org.qgis.qgis3.21928270.21929400', 'XPC_FLAGS': '0x0', 'GDAL_DRIVER_PATH': '/Applications/QGIS-LTR.app/Contents/MacOS/lib/gdalplugins', 'GDAL_DATA': '/Applications/QGIS-LTR.app/Contents/Resources/gdal', 'PYTHONHOME': '/Applications/QGIS-LTR.app/Contents/MacOS', 'GDAL_PAM_PROXY_DIR': '/Users/riku/Library/Application Support/QGIS/QGIS3/profiles/raster_plugin/gdal_pam/', 'LC_CTYPE': 'UTF-8', 'SSL_CERT_DIR': '/Applications/QGIS-LTR.app/Contents/Resources/certs', 'SSL_CERT_FILE': '/Applications/QGIS-LTR.app/Contents/Resources/certs/certs.pem', 'DYLD_LIBRARY_PATH': '/Applications/QGIS-LTR.app/Contents/MacOS/lib'})
Spartacus1 commented 2 years ago

Same here using Monterey and QGIS 3.26.3.

brentnk commented 2 years ago

I am having this same issue. 3.26.3 on Monterey 12.6.

i can think of two ways... do you use these algorithms directly (without qgis/processing)? one solution would allow it too, other one will not...

This seems to fix it.

bholtdwyer commented 1 year ago

I'm having this same problem when I try the Raster > Merge command on QGIS 3.22.8 on Mac OS 10.15.7.

--Edit: Fixed; problem is path to app is different for more recent QGIS: os.environ["PROJ_LIB"]="/Applications/QGIS-LTR.app/Contents/Resources/proj"

By the way, is there any way to update the Proj that QGIS uses? Mine seems to be using version 3 whereas the current version is 9.

malo6008 commented 1 year ago

I' m having the same issue on QGIS 3.28 LTR with MacOS 14.0. The above mentioned work-around solves the issue, but the next time I use QGIS the environment variable seems to be gone again. How can I make this work-around persistent?

CommunyAS commented 11 months ago

The problem still exists in QGIS-LTR 3.28.12-Firenze on macOS 13.6.

The solution suggested above in https://github.com/qgis/QGIS/issues/39801#issuecomment-725219034 does not work - at least for QGIS-LTR, since it will be installed as QGIG-LTR.app. The path must probably be adjusted accordingly (though I did not try using QGIS Python console)

There is another solution:

In QGIS Options you can specify the correct path under System > Environment by overwriting the _PROJLIB variabel with the correct path (restart required) - see screenshot below:

QGIS_custom_environment

This will fix the problem perhaps more permanently.

M-Alejo commented 2 months ago

Having the same issue when try to run GDAL "Asignar proyeccion" in QGIS 3.34.9 on MacOS Sonoma 14.6.

The solution of overwrite PROJ_LIB with the path /Applications/QGIS-LTR.app/Contents/Resources/proj works fine for me

image