This simple script retrieving a value of raster pixel size works in Python console, but can't be processed in Script editor: "No script found. Seems there is no valid script in the file." How could it be solved?

from qgis.core import QgsRasterLayer

ras = QgsRasterLayer(r"C:\Users\123\123.tif")
pixelsizeX = ras.rasterUnitsPerPixelX()
pixelsizeY = ras.rasterUnitsPerPixelY()
print (pixelsizeX)
print (pixelsizeY)
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Oct 3, 2023 at 10:04
  • This is not a valid processing script. Start your learning journey here. And pay attention to the tip here
    – Ben W
    Oct 3, 2023 at 10:32

1 Answer 1


That may be a valid pyqgis script, but it's not a valid processing script. You can run it from the console script editor, not the processing script editor.

enter image description here

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.