3

Background of my question: I would like to figure out the version of a plugin ('my_plugin'), in PyQGIS 2 like:

from qgis.utils import findPlugins
import os

plugins = list(findPlugins('C:\Users\me\.qgis2\python\plugins')) + list(findPlugins(os.environ['QGIS_PLUGINPATH']))
for p_name, p_info in plugins:
    if p_name == 'my_plugin':
        print(p_info.get('general', 'version'))

This works too in PyQGIS 3, except from the path where the plugins are stored (in QGIS 3 plugins are stored in the newly introduced user profiles, and from the GUI, the current plugin folder location can be accesses like described in this post: QGIS 3 Plugin folder location)

after some research my first idea was

from qgis.core import QgsUserProfile, QgsUserProfileManager
current_profile = QgsUserProfileManager().userProfile()
current_profile_folder = current_profile.folder()

... but current_profile is None.

So my question is: How to find the current user profiles plugin location using PyQGIS?

1 Answer 1

14

try:

from qgis.core import QgsApplication
QgsApplication.qgisSettingsDirPath()

for show profiles folder

https://qgis.org/api/classQgsApplication.html#a89ad50b0d0fd60ccae803f22f6c5cf46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.