Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. AttributeError: type object 'object' has no attribute '__getattr__'

AttributeError: type object 'object' has no attribute '__getattr__'

Scheduled Pinned Locked Moved Unsolved Qt for Python
9 Posts 3 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by john_hobbyist
    #1

    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
    
    . . .
    JonBJ 2 Replies Last reply
    0
    • J john_hobbyist

      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
      
      . . .
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @john_hobbyist
      I tried Googling the unique-looking in _swig_getattr_nondynamic. I suggest you do so to look at the several hits. Add osgeo 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.

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        The first thing to check is the validity of your "tif" object.

        As noted by @JonB, this looks like an issue with gdal so you should ping them.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • J Offline
          J Offline
          john_hobbyist
          wrote on last edited by
          #4

          From google search results seems to be a bug...I am searching it more though..

          1 Reply Last reply
          0
          • J john_hobbyist

            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
            
            . . .
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @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?

            J 1 Reply Last reply
            1
            • JonBJ JonB

              @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?

              J Offline
              J Offline
              john_hobbyist
              wrote on last edited by
              #6

              @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...

              JonBJ 1 Reply Last reply
              0
              • J john_hobbyist

                @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...

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @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.

                J 1 Reply Last reply
                0
                • JonBJ JonB

                  @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.

                  J Offline
                  J Offline
                  john_hobbyist
                  wrote on last edited by john_hobbyist
                  #8

                  @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.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    john_hobbyist
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved