I'm learning python and I'm also learning GIS (QGIS to be exact). What I'm trying to do is use the python console in QGIS to practice and get comfortable with python.
Tutorials that I have found are pretty straightforward. Moving forward, I'm looking at creating a package and calling that package in the QGIS python console. Specifically, I have created the following on: E:\OneDrive\Documents\PythonQGis\PythonScripts
# just a simple function to test accessibility. def getDefaultProjectCrs(): return iface.mapCanvas().mapRenderer().destinationCrs().authid()
I have also incuded
__init__.py file in the PythonScripts folder.
it has a single line:
__all__ = ["crsLayers"]
In my QGIS python console I issue the following commands:
import sys sys.path.append("E:\OneDrive\Documents\PythonQGis\PythonScripts")
I have tried the following:
import PythonScripts import PythonScripts.crsLayers crsLayers.getDefaultProjectCrs()
They all return error messages:
Traceback (most recent call last): File "", line 1, in File "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python\qgis\utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named PythonScripts.crsLayers
Traceback (most recent call last): File "", line 1, in NameError: name 'crsLayers' is not defined
What am I missing?