I am building a headless PyQGIS application that will need to be integrated into a bigger system.
Everything works, but when reading a layer from a GML file, the output keeps printing:
Cannot import http://spatialreference.org/ref/epsg/3812/ due to ALLOW_NETWORK_ACCESS=NO
It still all works fine, but the logging is annoying since it prints it about 8 times per layer and I have multiple layers. And it swamps our log management application.
qgis_app = QgsApplication([], False)
qgis_app.initQgis()
os.environ["ALLOW_NETWORK_ACCESS"] = "YES"
project = QgsProject.instance()
QgsSettings().setValue("qgis/networkAndProxy/networkAccessAllowed", True)
crs = QgsCoordinateReferenceSystem("EPSG:3812")
for layer_name in self.layer_names:
layer = QgsVectorLayer(f"{file}|layername={layer_name}", layer_name, "ogr", crs=crs)
As you can see, I've tried setting the environment variable and manually setting the CRS, but neither works.
It works from a Docker container using QGIS 3.34.
Any ideas?
proj.db
wherever on the path set in thePROJ_DATA
environment variable, which in my anaconda environment is set to$CONDA_PREFIX/share/proj
. See proj.org/en/stable/usage/environmentvars.html. Depending on where/how you installed QGIS and what platform you're on, you may need to look for it in other places.