danvk / oldnyc

Mapping photos of Old New York
Apache License 2.0
288 stars 132 forks source link

Not able to run crop_morphology.py #107

Open kaushikmit opened 8 years ago

kaushikmit commented 8 years ago

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 commented 8 years ago

Sounds like a Python 2/3 issue.

Jmuccigr commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

P.S. Just found a Python3 version!

thoroc commented 3 years ago

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 commented 3 years ago

P.S. Just found a Python3 version!

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