How to call a package in QGIS python console?

المشرف العام

Administrator
طاقم الإدارة
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

File: crsLayers.py

# 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 syssys.path.append("E:\OneDrive\Documents\PythonQGis\PythonScripts")I have tried the following:

import PythonScriptsimport PythonScripts.crsLayerscrsLayers.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

or

Traceback (most recent call last): File "", line 1, in NameError: name 'crsLayers' is not defined

What am I missing?



أكثر...
 
أعلى