Python Forum
can anyone help convert to python3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can anyone help convert to python3
#1
Hello i need a bit of help converting something created for python2 to work with python3.
here is what i need converting.
https://github.com/martinr1000/AliensMotionTracker
Can anyone convert this to work with python3
Reply
#2
Have you tried running it through 2to3?
Reply
#3
(Jul-15-2020, 03:15 PM)bowlofred Wrote: Have you tried running it through 2to3?

I have no idea how to use 2to3.
Reply
#4
Then try reading the documentation in the link provided.
Reply
#5
I did try but just did not understand anything.
Reply
#6
Make a copy of your program and run 2to3 on it with the -w flag. It will change the copy and you can try to run it. If you get output that you don't understand, you can ask about it here.
Reply
#7
I think i done it but it dose show lots of errors.
Quote: 2to3 -w /home/pi/tracker
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: No changes to /home/pi/tracker/audio.py
RefactoringTool: No changes to /home/pi/tracker/calibration.py
RefactoringTool: No changes to /home/pi/tracker/calibrationGraphics.py
RefactoringTool: No changes to /home/pi/tracker/compass.py
RefactoringTool: No changes to /home/pi/tracker/contacts.py
RefactoringTool: No changes to /home/pi/tracker/graphics.py
RefactoringTool: No changes to /home/pi/tracker/main.py
RefactoringTool: Refactored /home/pi/tracker/pyscope.py
--- /home/pi/tracker/pyscope.py (original)
+++ /home/pi/tracker/pyscope.py (refactored)
@@ -24,7 +24,7 @@
try:
pygame.display.init()
except pygame.error:
- print 'Driver: {0} failed.'.format(driver)
+ print('Driver: {0} failed.'.format(driver))
continue
found = True
break
RefactoringTool: Can't rename /home/pi/tracker/pyscope.py to /home/pi/tracker/py scope.py.bak
RefactoringTool: Can't create /home/pi/tracker/pyscope.py: [Errno 13] Permission denied: '/home/pi/tracker/pyscope.py'
Traceback (most recent call last):
File "/usr/bin/2to3", line 5, in <module>
sys.exit(main("lib2to3.fixes"))
File "/usr/lib/python3.7/lib2to3/main.py", line 259, in main
options.processes)
File "/usr/lib/python3.7/lib2to3/refactor.py", line 687, in refactor
items, write, doctests_only)
File "/usr/lib/python3.7/lib2to3/refactor.py", line 280, in refactor
self.refactor_dir(dir_or_file, write, doctests_only)
File "/usr/lib/python3.7/lib2to3/refactor.py", line 300, in refactor_dir
self.refactor_file(fullname, write, doctests_only)
File "/usr/lib/python3.7/lib2to3/refactor.py", line 728, in refactor_file
*args, **kwargs)
File "/usr/lib/python3.7/lib2to3/refactor.py", line 339, in refactor_file
write=write, encoding=encoding)
File "/usr/lib/python3.7/lib2to3/refactor.py", line 505, in processed_file
self.write_file(new_text, filename, old_text, encoding)
File "/usr/lib/python3.7/lib2to3/main.py", line 103, in write_file
shutil.copymode(backup, filename)
File "/usr/lib/python3.7/shutil.py", line 143, in copymode
st = stat_func(src)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/tracker/pyscop e.py.bak'
Reply
#8
Is the filesystem writable? Are you running 2to3 as the right user (i.e. one who has write permissions for that directory)?
Reply
#9
I have logged in as pi. So how do I get write permission? I’m new to this and old.

So I should use sudo 2to3.
Reply
#10
You shouldn't need to use sudo. Can you show the output of ls -l /home/pi/tracker?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  convert string into multiple columns in python3 VAN 2 2,781 Sep-26-2020, 11:14 PM
Last Post: scidam
  python3 convert hex to binary 32 bit Mkt 3 3,973 Aug-28-2020, 02:34 PM
Last Post: Mkt
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 4,933 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020