2

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?

Jochen Schwarze
  • 14,605
  • 7
  • 49
  • 117

1 Answers1

13

try:

from qgis.core import QgsApplication
QgsApplication.qgisSettingsDirPath()

for show profiles folder

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

Fran Raga
  • 7,838
  • 3
  • 26
  • 47