| | |
2to3
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
i have python 2.5 and 3 and i want to use 2to3 to convert all of my programs to python3 but i dont know how to use it, if it helps in the Lib folder of python3 it is called lib2to3.
any help or examples welcome.
any help or examples welcome.
don't judge me because I'm a year 8!
'it is better to fight for something than to live for nothing'General George S Patton
'it is better to fight for something than to live for nothing'General George S Patton
•
•
Join Date: Jul 2007
Posts: 66
Reputation:
Solved Threads: 14
open a terminal and go to your code directory.
type in the following:
The tool will then output all the changes that it can perform.
If you want to write the changes back to the file, use this command instead
Take a look at http://docs.python.org/3.0/library/2to3.html for more information
type in the following:
Python Syntax (Toggle Plain Text)
python path_to_2to3.py yoursourcefile.py
The tool will then output all the changes that it can perform.
If you want to write the changes back to the file, use this command instead
Python Syntax (Toggle Plain Text)
python path_to_2to3.py -w yoursourcefile.py
Take a look at http://docs.python.org/3.0/library/2to3.html for more information
i tried that in the cmd promt and it said that 'python wasnt a proper command' and im the python command line it said
invalid syntax and pointed to the
how can i fix this?
invalid syntax and pointed to the
Python Syntax (Toggle Plain Text)
yoursourcefile.py
how can i fix this?
don't judge me because I'm a year 8!
'it is better to fight for something than to live for nothing'General George S Patton
'it is better to fight for something than to live for nothing'General George S Patton
•
•
•
•
i tried that in the cmd promt and it said that 'python wasnt a proper command'
So instead of
python path_to_2to3 my_program.py you would need C:\\Python26\\python.exe path_to_2to3 my_program.py Or which ever version of Python is appropriate. Check your system in case you've installed python in a different directory.
Another way is to add C:\Python30 (since you don't have Python 2.6) and C:\Python30\Tools\Scripts to your PATH variable.
http://www.brightrev.com/how-to/wind...c.html?start=1
Be careful because if you mess it up some programs may stop working.
http://www.brightrev.com/how-to/wind...c.html?start=1
Be careful because if you mess it up some programs may stop working.
Last edited by scru; Apr 16th, 2009 at 11:59 am.
thanks scru that got rid of the first error but now i have the error of attempted relative import of non package.
how can i fix this?
Python Syntax (Toggle Plain Text)
from . import item
Last edited by leegeorg07; Apr 16th, 2009 at 1:36 pm.
don't judge me because I'm a year 8!
'it is better to fight for something than to live for nothing'General George S Patton
'it is better to fight for something than to live for nothing'General George S Patton
•
•
•
•
thanks scru that got rid of the first error but now i have the error of attempted relative import of non package.
how can i fix this?Python Syntax (Toggle Plain Text)
from . import item
its part of 2to3, its in __main__, this is where it is in the module:
Python Syntax (Toggle Plain Text)
import sys import os import logging import shutil import optparse from . import refactor
don't judge me because I'm a year 8!
'it is better to fight for something than to live for nothing'General George S Patton
'it is better to fight for something than to live for nothing'General George S Patton
Are you using Python30\python.exe or Python25\python.exe to run 2to3? I think 3.0 changed the way imports work so this script probably depends heavily on those changes.
![]() |
Similar Threads
- Starting Python (Python)
- Removing javascript from html (Python)
- having difficulties (Python)
- Python 3.0? (Python)
- Shutdown program (Python)
Other Threads in the Python Forum
- Previous Thread: mod_python apache2.2 Trouble in running python cgi scrpts
- Next Thread: why won't this counter work?
| Thread Tools | Search this Thread |
abrupt ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog data decimals dictionaries dictionary drive dynamic error examples excel exe file float format function gnu graphics gui heads homework http ideas import input java launcher leftmouse line linux list lists logging loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wikipedia windows write wxpython xlib






