Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 support #1

Open
mruegenberg opened this issue Apr 9, 2016 · 8 comments
Open

Python 3 support #1

mruegenberg opened this issue Apr 9, 2016 · 8 comments

Comments

@mruegenberg
Copy link

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.

@dsurujon
Copy link

Thank you so much for this! There's also another Exception in hdf5_dataset in line 85 that needs a syntax fix

@jimkon
Copy link

jimkon commented Dec 26, 2017

I run sudo 2to3 -w [pyflann directory in dist-packages] and worked.

@M00NSH0T
Copy link

M00NSH0T commented Mar 15, 2018

I tried following the instructions above, but I still got an error.
ArgumentError: argument 9: <class 'TypeError'>: expected LP_FLANNParameters instance instead of LP_FLANNParameters
In the end, jimkon's solution, however, worked fine. I had to switch to linux to run it obviously, but I can now run pyflann in windows after copying the modified files back over to my windows dist-packages folder.

It would be helpful to others I imagine if you could open up the Python3 branch of this so others could just install those files directly.

@ghost
Copy link

ghost commented Aug 6, 2019

@jimkon's solution works for me on OSX (10.14.4) with Python 3.7.4. I installed via pip, and then needed to specify an exception type for line 65 of binary_dataset.py:

63. else:
64.    if rows==-1 or cols==-1:
65.        #  raise "No .meta file present, you must specify dataset rows, cols asd dtype")
66.        raise ValueError("No .meta file present, you must specify dataset rows, cols asd dtype")

@abdor95
Copy link

abdor95 commented Dec 1, 2022

I followed the instructions but I am getting this error

raise ImportError('Cannot load dynamic library. Did you compile FLANN?') ImportError: Cannot load dynamic library. Did you compile FLANN?

@coamw2
Copy link

coamw2 commented Jun 27, 2023

I followed the instructions but I am getting this error

raise ImportError('Cannot load dynamic library. Did you compile FLANN?') ImportError: Cannot load dynamic library. Did you compile FLANN?

@abdor95 I also got this error. After some debug I found the exact error for me:
dlopen(.../pyflann/lib/python3.9/site-packages/pyflann/lib/darwin/libflann.dylib, 0x0006): tried: '.../pyflann/lib/darwin/libflann.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I am running on a new M chip macbook. If you had the same issue and found a solution let me know. I am going to build my project on an old intel macbook for now and look at migrating later.

@in509
Copy link

in509 commented Jul 30, 2023

I followed the instructions but I am getting this error
raise ImportError('Cannot load dynamic library. Did you compile FLANN?') ImportError: Cannot load dynamic library. Did you compile FLANN?

@abdor95 I also got this error. After some debug I found the exact error for me: dlopen(.../pyflann/lib/python3.9/site-packages/pyflann/lib/darwin/libflann.dylib, 0x0006): tried: '.../pyflann/lib/darwin/libflann.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I am running on a new M chip macbook. If you had the same issue and found a solution let me know. I am going to build my project on an old intel macbook for now and look at migrating later.

Hi, Do you happen to find a solution for the M chip issue

@ddarmon
Copy link

ddarmon commented Oct 11, 2023

This is old news, but I posted a solution to ^ here:

https://github.com/ddarmon/sidpy/#installation-on-arm-based-macs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants