嗨,在启动 QGIS3 时,我的 startup.py 脚本有以下代码,我想检查用户配置文件是否存在,如果不存在,则创建并加载它,但似乎这个过程陷入了某种不可阻挡的循环,使其无法使用该应用程序。
from qgis.core import *
from PyQt5 import *
import os import getpass
import qgis
defaultsti = QgsApplication.qgisSettingsDirPath()
os.chdir(defaultsti)
os.chdir(os.path.dirname(os.getcwd()))
r = os.getcwd()
a = QgsUserProfileManager(r).allProfiles()
g = getpass.getuser()
if QgsUserProfileManager(r).profileExists(g):
import qgis
qgis.core.QgsUserProfileManager(r).loadUserProfile(g)
else:
import qgis
import getpass
g = getpass.getuser()
qgis.core.QgsUserProfileManager(r).createUserProfile(g)
QgsUserProfileManager(r).loadUserProfile(g)
有没有办法解决这个问题?