Issue
I wrote a test code expression like
def test_trans():
dst_crs = QgsCoordinateReferenceSystem("EPSG:4326")
print(dst_crs)
assert True
I expected to get <QgsCoordinateReferenceSystem: EPSG:4326>, but instead, I received <QgsCoordinateReferenceSystem: invalid>.
After reviewing the output, I encountered the following message:
proj_create_from_database: Cannot find proj.db
Believing this to be the cause, do you know how to fix this error?
I would prefer not to use the method of manually entering environment variables, as it compromises the flexibility to work across various environments.
Thank you for taking the time to read this.
Steps to reproduce the issue
Clone the pytest-qgis repository using the following command:
$ git clone [email protected]:GispoCoding/pytest-qgis.gitMove to pytest-qgis
$ cd pytest-qgisFollow the steps below to set up the environment, as outlined in the 'Development Environment' section:
# Create a virtual environment using the Python that comes with QGIS. $ /your/QGIS/python/path -m venv .venv --system-site-packages $ source .venv/bin/activate $ python -m pip install -U pip setuptools $ pip install pip-tools $ pip-sync requirements.txt requirements-dev.txt $ pre-commit installPlace the following files in the 'tests' directory.
test_foo.py
from qgis.core import QgsCoordinateReferenceSystem def test_trans(): dst_crs = QgsCoordinateReferenceSystem("EPSG:4326") print(dst_crs) assert TrueExecute the test files using the following command:
$ pytest tests/test_foo.py -v -s
This error message means that
proj.dbdoesn't exists. You can resolve it by create the file and placing the values. Or if you don't want to manually create the file, you can write a python script to create the file. Also I think this might help you: https://gis.stackexchange.com/questions/378463/cannot-find-proj-db-and-error-1-proj-proj-create-from-database-cannot-builAnd don't forget to change the data and table name.