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.

python 3 compatibility

See original GitHub issue

it would be great to make this compatible with python 3!

i mentioned a problem in https://github.com/YadiraF/PRNet/issues/21 but wanted to start a fresh issue here.

$ python run_basics.py 
2018-05-01 12:16:47.603620: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1349] Found device 0 with properties: 
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6575
pciBusID: 0000:05:00.0
totalMemory: 10.91GiB freeMemory: 8.34GiB
2018-05-01 12:16:47.603651: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1428] Adding visible gpu devices: 0
2018-05-01 12:16:47.806106: I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-05-01 12:16:47.806140: I tensorflow/core/common_runtime/gpu/gpu_device.cc:922]      0 
2018-05-01 12:16:47.806148: I tensorflow/core/common_runtime/gpu/gpu_device.cc:935] 0:   N 
2018-05-01 12:16:47.806319: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1046] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8060 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:05:00.0, compute capability: 6.1)
2018-05-01 12:16:47.807380: I tensorflow/core/common_runtime/process_util.cc:64] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Traceback (most recent call last):
  File "run_basics.py", line 52, in <module>
    write_obj(os.path.join(save_folder, name + '.obj'), vertices, colors, prn.triangles) #save 3d face(can open with meshlab)
  File "/home/kyle/Documents/PRNet/utils/write.py", line 37, in write_obj
    f.write(s)
TypeError: a bytes-like object is required, not 'str'

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
awilliamsoncommented, May 4, 2018

Standard 2to3 write on everything works bar the bytes-str issue. Either do str.encode('utf-8') and b"my string" or as @YadiraF suggests by removing byte writing mode ( more sensible ). I have this working under Python 3 environment.

2reactions
983commented, May 3, 2018

run_basics.py worked for me after changing the 'wb' to 'w' in 3 places:

https://github.com/YadiraF/PRNet/blob/master/utils/write.py#L31 https://github.com/YadiraF/PRNet/blob/master/utils/write.py#L66 https://github.com/YadiraF/PRNet/blob/master/utils/write.py#L89

Additionally, I had to create the directory AFLW2000 in TestImages/AFLW2000_results to get TestImages/AFLW2000_results/AFLW2000.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Porting Python 2 Code to Python 3 — Python 3.11.1 ...
And that's mostly it! At this point your code base is compatible with both Python 2 and 3 simultaneously. Your testing will also...
Read more >
Cheat Sheet: Writing Python 2-3 compatible code
This notebook shows you idioms for writing future-proof code that is compatible with both versions of Python: 2 and 3. It accompanies Ed...
Read more >
How to detect if code is python 3 compatible - Stack Overflow
You can use Pycharm IDE for this. Just open the python files in the pycharm editor, it will show warnings ...
Read more >
Python 3 Custom Check Migration - Datadog Docs
Use Datadog's Custom Check Compatibility tool to see whether your custom checks are compatible with Python 3 or need to be migrated.
Read more >
Supporting Python 2 and 3 without 2to3 conversion
Python 2.7 has some small improvements on Python 3 compatibility, but it's likely that if you want to run the same code under...
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