Skip to content

Python 3 support #1

@mruegenberg

Description

@mruegenberg

Hi,
I'm getting some errors when using Python 3 (3.4.3) (and installing from pip, pyflann 1.6.12).

  • I'm getting import errors due to relative imports. The solution is to replace various from foo import * with from .foo import *.
    See also here
    (This should also work in Python 2.)

    specifically:

    • bindings/init.py
    • the pyflann imports in index.py
    • both imports in init.py
    • io/init.py
    • the _dataset imports in io/dataset.py need to be relative as well, e.g from . import binary_dataset
  • after fixing these, I get invalid syntax in find_ctypes.py, line 151. The reason is that the except Exception, e syntax was replaced by except Exception as e:.
    In this case, it could just be except Exception:

  • same in io/dataset.py, line 61 and hdf5_dataset, line 34+67

  • in flann_ctypes, line 201, the exec call needs brackets

  • Python 3 no longer contains dict.iteritems and should be replaced by dict.items (in flann_ctypes, l.53 and 78)

(Not sure if this is the right place for these issues, I just followed the pip package to its source.)

Some additional errors which I'm not sure are the fault of Python 3:

  • I get an error about flann_parameters missing when __del is called. Apparently, they are deleted before the del call?

With these fixes, pyflann seems to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions