Python Forum
Trying to convert a script from "2to3"
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to convert a script from "2to3"
#1
I cannot for the life of me get 2to3 work for me and I was wondering if anyone would be gracious enough to help me out with it. I would sincerely appreciate it.
Reply
#2
Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?
Reply
#3
(Feb-21-2017, 02:22 AM)micseydel Wrote: Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?

Hello! Thank you for responding!

I am using this video as a reference:


It does it's thing, but never tells me to "try" to fix anything. So, I assumed that it corrected all of the mistakes, I typed -w in my command to write it and it created the script and the backup, but when I remove Python2, it asks me what program I want to use to open it. When I choose Python (33), it opens the program, but it's not working correctly. Basically, it is supposed to "sign" tga images with specific names. But even though it is in the same folder with the tga files, it's like they don't exist if that makes any sense at all. Am I allowed to post my script here? I am a complete infant when it comes to this so please bear with me.

(Feb-21-2017, 02:22 AM)micseydel Wrote: Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?

Here is the Python 2 script:

And here is the 2to3 converted Python 3 script:

Reply
#4
and what comes out as py3 code that does not work? (/me not looking at the code, yet)
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
(Feb-21-2017, 06:29 AM)Skaperen Wrote: and what comes out as py3 code that does not work?  (/me not looking at the code, yet)


It states that the files are not found, even though they are in the same folder as the script, which is how it is supposed to be.
Reply
#6
in line 8 of either source code where does the variable name file come from?

is this "files not found" issue happening when you run your script or when you run 2to3 ?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#7
Files (I assume that's the tga files) not found sounds like problem with the way you run the script (i.e. paths where it is looking for the files), not a problem with 2to3 conversion.

by the way file is built-in function in python2 so I would not use it as argument to the functions. Same for type.
Reply
#8
file is gone in python 3.   so i wonder how 2to3 will handle that
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#9
(Feb-21-2017, 08:41 AM)Skaperen Wrote: file is gone in python 3.   so i wonder how 2to3 will handle that

You can look at the result code posted by the OP. Anyway I don't think this could cause problem as long as he doesn't try to use it as originally intended.
Note that it doesn't rise an exception, just os.path.exists cannot find the files.
Reply
#10
Thank you guys for your help! The picture below is how it should look, but instead, it says that the files can't be found, but that they were verified.

[Image: fwhfgi.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Script to convert Json to CSV file chvsnarayana 8 2,496 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
Question convert autohotkey script to python / macro - press key when pixel get colour willson94d 1 3,635 Jan-01-2022, 08:13 PM
Last Post: Yoriz
  Convert .py script to dll file and .exe srikanthpython 0 3,126 Aug-20-2020, 06:01 PM
Last Post: srikanthpython
  Convert Python script to Php JuroClash 0 8,142 Oct-21-2019, 03:01 PM
Last Post: JuroClash
  convert sh script to python script Reims 0 2,143 Oct-01-2019, 12:10 PM
Last Post: Reims
  Is there any way to convert a python script (with Tkinter module), to a .exe (Windows moste 3 4,000 May-12-2019, 12:02 PM
Last Post: snippsat
  How to use 2to3.py converter under Windows OS samsonite 2 7,294 Mar-02-2019, 05:49 AM
Last Post: samsonite
  Confusing output from 2to3 about what files need change Moonwatcher 1 4,820 Dec-30-2018, 04:07 PM
Last Post: Gribouillis
  Issue with a script to convert xls to json Will86 2 3,804 Dec-19-2018, 08:23 AM
Last Post: Will86
  Error with using pyinstaller to convert python script in Mac OS Takeshio 2 5,363 Oct-19-2018, 02:42 PM
Last Post: Takeshio

Forum Jump:

User Panel Messages

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