I'm encountering a persistent issue in my QGIS environment where Processing Algorithms fail to run after the second execution, consistently showing an "Algorithm not found" error. This happens even for standard algorithms provided by QGIS and not just custom scripts.
In Detail: On the first run of my script, I execute Processing Algorithms, such as "qgis:hillshade," successfully. On the second run executing the same algorithm (or any other Processing Algorithm) I consistently get the error message: "Algorithm not found." I make no changes to my QGIS environment, the algorithm itself, or the data. I don't know why the algorithms suddenly become inaccessible.
This problem occurs since I added a code to open a custom parameter selection dialog. I think the code shouldn't interfere with the availability of standard QGIS Processing Algorithms, but if I comment this part, the script runs fine every time. So I guess the code somehow messes with my environment. I tried with fresh environment and checked the Python executable path used by QGIS, which in both cases is the same. After the second execution I tried running the algorithm using the toolbox which worked. I copied the code from processing history and tried running the same algorithm with the interpreter and I get the same error again.
What could be causing this issue? Is there a way to troubleshoot and resolve this error?
i use Mac 12.6.6 and my QGIS Version is 3.22.5-Białowieża.
from qgis.PyQt.QtWidgets import QApplication, QDialog, QLabel, QVBoxLayout, QPushButton, QComboBox
# Create a custom dialog
class ParameterSelectionDialog(QDialog):
def __init__(self, parent=None):
super(ParameterSelectionDialog, self).__init__(parent)
self.setWindowTitle("Parameter Selection")
layout = QVBoxLayout()
# Explanation labels for parameters
explanations = {
"d0": "choose snowdepth, return periode, dirftsnow ",
"fillsink": "choose if pcm should fillsink in DTM",
"avalanche": "choose Avalanche Size"
}
for param, explanation in explanations.items():
label = QLabel(f"{explanation}:")
layout.addWidget(label)
# Dropdown menu for parameter values
combo_box = QComboBox()
if param == "d0":
combo_box.addItems(["d0", "d0_30", "d0_50", "d0100", "d0100_30", "d0100_50","d0300", "d0300_30", "d300_50" ])
elif param == "fillsink":
combo_box.addItems(["Y", "N"])
elif param == "avalanche":
combo_box.addItems(["XL", "L", "M", "XS"])
layout.addWidget(combo_box)
close_button = QPushButton("Close")
close_button.clicked connect(self.accept)
layout.addWidget(close_button)
self.setLayout(layout)
# Create the application and show the dialog
app = QApplication([])
dialog = ParameterSelectionDialog()
dialog.exec_()