Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find proj.db in QGIS-LTR 3.22; PROJ_LIB env variable not set #151

Open
Rikuoja opened this issue May 25, 2022 · 4 comments
Open

Cannot find proj.db in QGIS-LTR 3.22; PROJ_LIB env variable not set #151

Rikuoja opened this issue May 25, 2022 · 4 comments

Comments

@Rikuoja
Copy link

Rikuoja commented May 25, 2022

Since the corresponding issue(s) in QGIS have been closed, I should report this here:

qgis/QGIS#39801
qgis/QGIS#48574

I have the same problem in all QGIS 3.22 versions on MacOS, including LTR. Trying to run etc. gdalwarp results in

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

I suspect this is because the PROJ_LIB env variable is not set in QGIS python environment. All the other GDAL variables are set correctly:

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'})

There is a merged commit 18f8180 that should have fixed this issue. The commit seems to set env variables, including PROJ_LIB.

However, in 3.22 PROJ_LIB is still not set.

@spatialthoughts
Copy link

Confirm this is still a problem with the latest LTR 3.22.8 as well.

@yukihuang0422
Copy link

Hi, Since it is still a problem in 3.22.8, how can I merge rasters in 3.22.8?
I have tried the method in #39801, which is
import os
os.environ["PROJ_LIB"]="/Applications/QGIS.app/Contents/Resources/proj"
But it doesn't work.
How can I merge rasters now?

@rickyking
Copy link

Just figure out a temporary solution for this: Option - System - Environment and set the PROJ_LIB. Restart!

image

@kidhanis
Copy link

Same issue on QGIS version 3.32.2-Lima running on MacOS 10.13.6.

I looked around the code for PROJ_LIB, and found _patch_proj_lib.py, which adds the variable if missing. If this file is still in use, then I might have found a possible cause of the bug.

Possible regression

The only place where _patch_proj_lib is mentioned in the repository is in python_pyproj/recipe.sh:

try cp -av $RECIPES_PATH/python_pyproj/_patch_proj_lib.py $PYPROJ_EGG/pyproj/_patch_proj_lib.py
try ${SED} "s;from pyproj import _datadir;from pyproj import _patch_proj_lib, _datadir;g" $PYPROJ_EGG/pyproj/__init__.py

The sed command in line 40 adds _patch_proj_lib to a line matching from pyproj import _datadir inside pyproj/__init__.py. Locally, this file is in
/Applications/QGIS.app/Contents/Resources/python/site-packages/pyproj-3.2.0-py3.9-macosx-10.13.0-x86_64.egg/pyproj/__init__.py.
However, the line from pyproj import _datadir is nowhere to be found as it seems it was removed from pyproj a while back. Therefore, sed does nothing and the patch is not imported.

Could it be that_patch_proj_lib.py was added to QGIS-Mac-Packager before the updated pyproj was added to QGIS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants