TransWikia.com

Get folder path to QGIS processing scripts from PyQGIS

Geographic Information Systems Asked on May 13, 2021

Where is stored path to processing scripts folder in PyQGIS?

Version of QGIS is 3.16.

I want to get this path by Python script.

Path in QGIS GUI

I suppose then, is stored in processing object:

from qgis import processing

2 Answers

My solution is:

from processing.core.ProcessingConfig import ProcessingConfig
print(ProcessingConfig.getSetting('SCRIPTS_FOLDERS'))

is simple and works at Python Console (opened QGIS project)

Correct answer by Wenceslauw on May 13, 2021

If you have not changed the default path, you can recreate it using the path of your profile using qgisSettingsDirPath method from the QgsApplication class.

user_directory = QgsApplication.qgisSettingsDirPath()
print(user_directory) 
# C:/Users/vaclav/AppData/Roaming/QGIS/QGIS3profilesdefault/

processing_directory = os.path.join(user_directory,'processing/scripts')
print(processing_directory) 
# C:/Users/vaclav/AppData/Roaming/QGIS/QGIS3profilesdefault/processing/scripts

Answered by Vincent Bré on May 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP