Closed nakamori1024 closed 3 months ago
Thank you for the detailed issue! This is probably related to this one: https://github.com/GispoCoding/pytest-qgis/issues/56 but now that you have found a proper workaround it definitely helps finding the solution for the bug.
Thank you for your quick response! I initially thought this might be a separate issue due to differences in QGIS versions. However, I appreciate the reference to issue #56 and will review it for any potential overlap. Looking forward to any updates on this issue. Thank you again for your efforts and for maintaining such a valuable project.
Looking forward to any updates on this issue. Thank you again for your efforts and for maintaining such a valuable project.
Thank you! :) I'll do my best to get this fixed soon.
I initially thought this might be a separate issue due to differences in QGIS versions.
I completely missed your QGIS version, you are probably right and this might not be related to that after all.
I tried to reproduce the problem with multiple different QGIS versions on Windows 10 and multiple Linux distros including docker image of QGIS 3.28.15 (based on Ubuntu 22.04.3). However I could not reproduce the issue since QGIS was always able to find proj.db.
I tried the script you provided for finding the proj.db automatically, but It tried to find proj.db from weirdest places, including:
Also wrong proj.db versions caused some unwanted error messages, like
GDAL ERROR 1: PROJ: proj_create_from_database: /home/
/.local/share/containers/storage/volumes/buildx_buildkit_default_state/_data/runc-overlayfs/snapshots/snapshots/22/fs/usr/share/proj/proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 3 is expected. It comes from another PROJ installation.
Although some libraries, like rasterio provide bundled proj.db, I don't think it is meaningful in this case since correct proj is installed when installing QGIS in most cases.
I think that the most robust way would be to export LIB_PROJ environment variable manually in your environment before running the tests.
Sorry for the delayed response.
Unfortunately, I still cannot find the proj.db in my environment. However, since you confirmed that it worked in multiple environments without any issues, it might be a problem specific to my environment.
Thank you very much for your support.
Dear developers.
Describe the bug "pytest-qgis" can't find proj.db.
To Reproduce Steps to reproduce the behavior:
Follow the steps below to set up the environment, as outlined in the 'Development Environment' section:
Place the following files in the 'tests' directory. test_foo.py
def test_trans(): dst_crs = QgsCoordinateReferenceSystem("EPSG:4326") print(dst_crs) assert True
$ pytest tests/test_foo.py -v -s
proj_create_from_database: Cannot find proj.db
DEFAULT_CRS = QgsCoordinateReferenceSystem("EPSG:4326")
import os import sys
found = False for pypath in sys.path: if found: break check_path = os.path.dirname( os.path.dirname(os.path.dirname(os.path.dirname(pypath))) ) for root, dirs, files in os.walk(check_path): if "proj.db" in files: proj_path = os.path.join(root, "proj.db") os.environ["PROJ_LIB"] = os.path.dirname(proj_path) found = True break