AttributeError: type object 'object' has no attribute '__getattr__'
-
Hello I have made a PyQt application where I load UAV images and I display the coordinates according to where the mouse pointer shows. I use this code: https://gis.stackexchange.com/questions/299571/converting-a-pixel-coordinate-in-geotiff-to-a-latitude-and-longitude inside a try...except. When running the code, I get this error. Any ideas?
Traceback (most recent call last): File "/home/john/.local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 224, in process func(*args, **kwargs) File "/home/john/.local/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3005, in mouse_move self.set_message(s) File "code.py", line 151, in set_message gt = tif.GetGeotransform() File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 2045, in <lambda> __getattr__ = lambda self, name: _swig_getattr(self, Dataset, name) File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 74, in _swig_getattr return _swig_getattr_nondynamic(self, class_type, name, 0) File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 69, in _swig_getattr_nondynamic return object.__getattr__(self, name) AttributeError: type object 'object' has no attribute '__getattr__'
Part of the code inside try...except:
. . . import gdal tif = gdal.Open('UAV.tif') gt = tif.GetGeotransform() x_min = gt[0] x_size = gt[1] y_min = gt[3] y_size = gt[5] mx, my = x, y # I feed x,y from pixel coordinates px = mx * x_size + x_min #x pixel py = my * y_size + y_min #y pixel . . .
-
Hello I have made a PyQt application where I load UAV images and I display the coordinates according to where the mouse pointer shows. I use this code: https://gis.stackexchange.com/questions/299571/converting-a-pixel-coordinate-in-geotiff-to-a-latitude-and-longitude inside a try...except. When running the code, I get this error. Any ideas?
Traceback (most recent call last): File "/home/john/.local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 224, in process func(*args, **kwargs) File "/home/john/.local/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3005, in mouse_move self.set_message(s) File "code.py", line 151, in set_message gt = tif.GetGeotransform() File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 2045, in <lambda> __getattr__ = lambda self, name: _swig_getattr(self, Dataset, name) File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 74, in _swig_getattr return _swig_getattr_nondynamic(self, class_type, name, 0) File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 69, in _swig_getattr_nondynamic return object.__getattr__(self, name) AttributeError: type object 'object' has no attribute '__getattr__'
Part of the code inside try...except:
. . . import gdal tif = gdal.Open('UAV.tif') gt = tif.GetGeotransform() x_min = gt[0] x_size = gt[1] y_min = gt[3] y_size = gt[5] mx, my = x, y # I feed x,y from pixel coordinates px = mx * x_size + x_min #x pixel py = my * y_size + y_min #y pixel . . .
@john_hobbyist
I tried Googling the unique-lookingin _swig_getattr_nondynamic
. I suggest you do so to look at the several hits. Addosgeo
to it (in _swig_getattr_nondynamic osgeo
) and you get some just like yours. I don't know whether this indicates there is a problem in something you do in your code or is inherent in the library you use, you'll have to investigate or ask in an appropriate forum. -
From google search results seems to be a bug...I am searching it more though..
-
Hello I have made a PyQt application where I load UAV images and I display the coordinates according to where the mouse pointer shows. I use this code: https://gis.stackexchange.com/questions/299571/converting-a-pixel-coordinate-in-geotiff-to-a-latitude-and-longitude inside a try...except. When running the code, I get this error. Any ideas?
Traceback (most recent call last): File "/home/john/.local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 224, in process func(*args, **kwargs) File "/home/john/.local/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3005, in mouse_move self.set_message(s) File "code.py", line 151, in set_message gt = tif.GetGeotransform() File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 2045, in <lambda> __getattr__ = lambda self, name: _swig_getattr(self, Dataset, name) File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 74, in _swig_getattr return _swig_getattr_nondynamic(self, class_type, name, 0) File "/home/john/.local/lib/python3.8/site-packages/osgeo/gdal.py", line 69, in _swig_getattr_nondynamic return object.__getattr__(self, name) AttributeError: type object 'object' has no attribute '__getattr__'
Part of the code inside try...except:
. . . import gdal tif = gdal.Open('UAV.tif') gt = tif.GetGeotransform() x_min = gt[0] x_size = gt[1] y_min = gt[3] y_size = gt[5] mx, my = x, y # I feed x,y from pixel coordinates px = mx * x_size + x_min #x pixel py = my * y_size + y_min #y pixel . . .
@john_hobbyist said in AttributeError: type object 'object' has no attribute '__getattr__':
inside a try...except. When running the code,
One thing. If you're diagnosing an error the last thing you want is a
try: ... except: ...
around the code. Comment that out, let it crash. The traceback you get should emanate from some line in your code, you might as well know which one.tif = gdal.Open('UAV.tif')
Is this succeeding?
-
@john_hobbyist said in AttributeError: type object 'object' has no attribute '__getattr__':
inside a try...except. When running the code,
One thing. If you're diagnosing an error the last thing you want is a
try: ... except: ...
around the code. Comment that out, let it crash. The traceback you get should emanate from some line in your code, you might as well know which one.tif = gdal.Open('UAV.tif')
Is this succeeding?
@JonB said in AttributeError: type object 'object' has no attribute '__getattr__':
@john_hobbyist said in AttributeError: type object 'object' has no attribute '__getattr__':
inside a try...except. When running the code,
One thing. If you're diagnosing an error the last thing you want is a
try: ... except: ...
around the code. Comment that out, let it crash. The traceback you get should emanate from some line in your code, you might as well know which one.tif = gdal.Open('UAV.tif')
Is this succeeding?
I have put print commands before and after this line. It crashes at this specific point. It does not execute this command...
-
@JonB said in AttributeError: type object 'object' has no attribute '__getattr__':
@john_hobbyist said in AttributeError: type object 'object' has no attribute '__getattr__':
inside a try...except. When running the code,
One thing. If you're diagnosing an error the last thing you want is a
try: ... except: ...
around the code. Comment that out, let it crash. The traceback you get should emanate from some line in your code, you might as well know which one.tif = gdal.Open('UAV.tif')
Is this succeeding?
I have put print commands before and after this line. It crashes at this specific point. It does not execute this command...
@john_hobbyist
Well, it's not that it does not execute it, it is that it does execute it and the error occurs during execution!If that is a file(?), please ensure it is accessible via that path before you go any further.
-
@john_hobbyist
Well, it's not that it does not execute it, it is that it does execute it and the error occurs during execution!If that is a file(?), please ensure it is accessible via that path before you go any further.
@JonB said in AttributeError: type object 'object' has no attribute '__getattr__':
@john_hobbyist
Well, it's not that it does not execute it, it is that it does execute it and the error occurs during execution!If that is a file(?), please ensure it is accessible via that path before you go any further.
Sorry, I was just checking 2-3 different .tif. Again the same message.
-
A small correction, the code is not running inside the try...except block. I have removed the try...except block, so the errors' line is for the code not running inside try..except block.