question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unicode String and Integer Division related crashes (python2 vs. python3)

See original GitHub issue

My attempted command is python3 ideepcolor.py --cpu_mode All dependencies seem to have installed correctly. I am obtaining the following crash on Intel i3 w/ Debian 9 Codename Stretch:

b'test_imgs/mortar_pestle.jpg'
Traceback (most recent call last):
  File "ideepcolor.py", line 60, in <module>
    window = gui_design.GUIDesign(color_model=colorModel, dist_model=distModel, img_file=args.image_file, load_size=args.load_size, win_size=args.win_size)
  File "/home/bb/ideepcolor/ui/gui_design.py", line 112, in __init__
    self.drawWidget.init_result(img_file)
  File "/home/bb/ideepcolor/ui/gui_draw.py", line 54, in init_result
    self.read_image(image_file.encode('utf-8'))  # read an image
  File "/home/bb/ideepcolor/ui/gui_draw.py", line 79, in read_image
    im_bgr = cv2.imread(image_file)
TypeError: bad argument type for built-in operation

Thanks for your help.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Benitoitecommented, Feb 21, 2018

I see https://github.com/junyanz/interactive-deep-colorization/blame/python3/ui/gui_draw.py Strings are already unicode in python3 whereas python2 is old-fashioned ASCII, requiring conversion. You may want a python3 branch. https://github.com/Benitoite/interactive-deep-colorization/tree/python3 Perhaps a python2/python3 conditional is possible.

I think sometimes people’s OS/distribution will allow either one or both pythons, sometimes because of package managers or a dependencies python hook locked to one version.

1reaction
junyanzcommented, Feb 19, 2018

Thanks for the update. I fixed the integer division issue with the latest commit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3 strange division - Stack Overflow
Python 3 is not "rounding big integers". What it does is that it will return a float after division. Hence, in Python 2:...
Read more >
The Key Differences Between Python 2 and Python 3
Unicode Strings: Python 3 stores strings as Unicode by default, whereas Python 2 requires you to mark a string with a “u” if...
Read more >
Python 2 vs. Python 3 — Important Differences Every Hacker ...
Python 3 also handles the division of integers differently. In version 2, dividing two integers would yield an integer as a result:
Read more >
The key differences between Python 2.7.x and Python 3.x with ...
Unicode. Python 2 has ASCII str() types, separate unicode() , but no byte type. Now, in Python 3, we finally have Unicode (utf-8)...
Read more >
Differences with Python 2 - Dodona
In Python 3, it is automatically assumed that if you use division, ... The way Python 2 works is similar to what most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found