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

Not able to run crop_morphology.py #107

Open
kaushikmit opened this issue Jan 19, 2016 · 6 comments
Open

Not able to run crop_morphology.py #107

kaushikmit opened this issue Jan 19, 2016 · 6 comments

Comments

@kaushikmit
Copy link

I get an error while compiling crop_morphology.py . It also shows undefined error with the print statements.

It also shows an error in the following line:
borders.sort(key=lambda (i, x1, y1, x2, y2): (x2 - x1) * (y2 - y1))

Can anyone help me in running this file successfully ?

@danvk
Copy link
Owner

danvk commented Jan 19, 2016

Sounds like a Python 2/3 issue.

@Jmuccigr
Copy link

Jmuccigr commented Jun 6, 2017

I may be having a similar issue.

First, PIL seems to have been replaced by Pillow, so I changed that import on line 24 to indicate Pillow instead.

Since that was in python 3 on my system, I changed the first line to

#!/usr/bin/env python3

Now I get the error:

  File "Downloads/crop_morphology.py", line 168
    print '%d %s -> %s / %s (%s), %s -> %s / %s (%s), %s -> %s' % (
                                                              ^
SyntaxError: invalid syntax

My python skills are minimal, so I don't immediately see what's wrong with that print statement. Or maybe it's something else?

@outkaj
Copy link

outkaj commented Jun 27, 2017

Try using 2to3 to convert the script from Python 2 to 3 (worked for me when getting the same error). To make the changes persistent:

2to3 crop_morphology.py -w

@outkaj
Copy link

outkaj commented Jun 27, 2017

P.S. Just found a Python3 version!

@thoroc
Copy link

thoroc commented Aug 23, 2020

It is a python 2 -> 3 issue. The solution is considering how to access the values inside the tuple object borders:

    # https://www.python.org/dev/peps/pep-3113/
    borders.sort(key=lambda x: (x[3] - x[1]) * (x[4] - x[2]))

@Jmuccigr
Copy link

P.S. Just found a Python3 version!

That user doesn't seem to be on GitHub anymore. Maybe this?

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

5 participants