შეცდომები და მათი მოგვარება
🔎🔎🔎¶
- დირექტორია (paths) → გამოიყენე
r"path"ან ორმაგი\
Info
გადახედე კიდევ ერთხელ განმარტებებში "დახრილი ხაზი" იგივე "Python-ში დირექტორიების სწორად ჩაწერა" - ს.
- EOL while scanning string → ფაილის დირექტორიის მისამართს აკლია ბრჭყალი
".
EOL means end of line, and the message means that Python reached the end of the line of code while processing the string on line 2. The path string needs another quotation mark to finish it. -
QVariant.Int → AttributeError: type object 'QVariant' has no attribute 'int' → პატარა
iშეცდომაა, სწორიაInt. -
Missing functions in IDE → თუ ფუნქციები არ ჩანს, მაშინ qgis მოდული უნდა შემოიტანო კოდის დასაწყისში.
- TEMPORARY_OUTPUT → დროებითი შედეგი, თუ გვინდა ფაილად შევინახოთ → ჩავანაცვლოთ
output
Warning
სხვა შემთხვევაში პროგრამის დახურვის შემდეგ მიღებული შედეგები დაიკარგება.
layers = QgsProject.instance().mapLayersByName('sadguri')
layer = layers[0]
delf = layer.dataProvider().capabilities()
feats = layer.getFeatures()
dfeats = []
კოდის ნაწილია წარმოდგენილი და თუ შეცდომას აგდებს
IndexError: list index out of range ნიშნავს რომ mapLayersByName('sadguri') სახელი შრის არ გაქვს შეცვლილი და ვერ ხვდება.
--
out = r'C:\Users\Public\GIS\PyGK\tema_4_1\Georgia_municipalities2.shp'
processing.run("native:deletecolumn", {INPUT': layer,\
'COLUMN':['SHAPE_Leng'],'OUTPUT':out})
EOL while scanning string literal
შეცდომა ნიშნავს რომ 'INPUT': - ს აკლია ' ცალ მხარეს
layer = layes[0]
NameError: name 'layes' is not defined
layes აკლია r - layers
proces sing.run("native:deleteduplicategeometries", {'INPUT':layer,'OUTPUT':output})
invalid syntax შეცდომა proces sing.run ერთად უნდა ეწეროს processing.run
სვეტი რომელსაც სკრიპტი ეძებს ატრიბუტულ ცხრილში ფიზიკურად არ არსებობს...
ამ შემთხვევაში ეს არის fid სვეტი.
Traceback (most recent call last):
File "", line 1, in
File "
KeyError: 'fid'
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.2\apps\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "
KeyError: 'X_coordinate'
ნიშნავს რომ კოდში დაწერილი
pv.addAttributes([QgsField('Area_sq_m', QVariant.Double)])
სვეტის ეს სახელწოდება არის გრძელი შეიპისთვის და უნდა შემოკლდეს
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "
File "C:\PROGRA~1/QGIS33~1.2/apps/qgis/./python\qgis\core\additions\edit.py", line 38, in enter
assert self.layer.startEditing()
AssertionError
შრის რედაქტირება გარსიდან უკვე ჩართული გაქვს და უნდა გათიშო
განმარტება
'', შრის სახელწოდებაა
iface.addVectorLayer(fn, '', 'ogr')
NameError: name 'Region' is not defined ნიშნავს რომ [Region] ჩასმული უნდა იყოს ფრჩხილებში >>> ['Region']
processing.run("native:dissolve", {'INPUT':layer ,'FIELD':['Region'],\
'SEPARATE_DISJOINT':False,'OUTPUT':fn})
NameError: name 'f' is not defined
iface.addVectorLayer(f, '', 'ogr')
iface.addVectorLayer(fაქ აკლია n ასო და მაგიტომ ვერ ხედავს, '', 'ogr')
iface.addVectorLayer(fn, '', 'ogr')