Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   2to3 Help? (http://www.velocityreviews.com/forums/t665581-2to3-help.html)

marco.m.petersen@gmail.com 01-15-2009 06:01 AM

2to3 Help?
 
I have Python 3.0. I tried to use the 2to3 program included with the
interpreter to convert some scripts for Python 2.5 to Python 3.0 ones.
When I try to start it form the Python command line, it says it is a
syntax error.

This was the line of code:

$ 2to3 testscript.py

Any help would be appreciated.

Thanks
- Marco

James Mills 01-15-2009 06:09 AM

Re: 2to3 Help?
 
On Thu, Jan 15, 2009 at 4:01 PM, <marco.m.petersen@gmail.com> wrote:
> I have Python 3.0. I tried to use the 2to3 program included with the
> interpreter to convert some scripts for Python 2.5 to Python 3.0 ones.
> When I try to start it form the Python command line, it says it is a
> syntax error.
>
> This was the line of code:
>
> $ 2to3 testscript.py
>
> Any help would be appreciated.


$ 2to3 testscript.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Can't open testscript.py: [Errno 2] No such file or
directory: 'testscript.py'
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't open testscript.py: [Errno 2] No such file or
directory: 'testscript.py'

Seems to work perfectly fine here.

It would greatly help if you showed us the error!

cheers
James

marco.m.petersen@gmail.com 01-15-2009 06:17 AM

Re: 2to3 Help?
 
On Jan 15, 2:09*pm, "James Mills" <prolo...@shortcircuit.net.au>
wrote:
> On Thu, Jan 15, 2009 at 4:01 PM, *<marco.m.peter...@gmail.com> wrote:
> > I have Python 3.0. I tried to use the 2to3 program included with the
> > interpreter to convert some scripts for Python 2.5 to Python 3.0 ones.
> > When I try to start it form the Python command line, it says it is a
> > syntax error.

>
> > This was the line of code:

>
> > $ 2to3 testscript.py

>
> > Any help would be appreciated.

>
> $ 2to3 testscript.py
> RefactoringTool: Skipping implicit fixer: buffer
> RefactoringTool: Skipping implicit fixer: idioms
> RefactoringTool: Skipping implicit fixer: set_literal
> RefactoringTool: Skipping implicit fixer: ws_comma
> RefactoringTool: Can't open testscript.py: [Errno 2] No such file or
> directory: 'testscript.py'
> RefactoringTool: No files need to be modified.
> RefactoringTool: There was 1 error:
> RefactoringTool: Can't open testscript.py: [Errno 2] No such file or
> directory: 'testscript.py'
>
> Seems to work perfectly fine here.
>
> It would greatly help if you showed us the error!
>
> cheers
> James


The error was:

>>> $ 2to3.py testscript.py

File "<stdin>", line 1
$ 2to3.py testscript.py
^
Syntax Error: Invalid Syntax

>>>



James Mills 01-15-2009 06:24 AM

Re: 2to3 Help?
 
On Thu, Jan 15, 2009 at 4:17 PM, <marco.m.petersen@gmail.com> wrote:
>>>> $ 2to3.py testscript.py

> File "<stdin>", line 1
> $ 2to3.py testscript.py
> ^
> Syntax Error: Invalid Syntax


Oh i see...

You need to do 2 things:

1) Run 2to3 on the shell not the python interpreter.
2) Learn some basic UNIX.

cheers
James

marco.m.petersen@gmail.com 01-15-2009 06:32 AM

Re: 2to3 Help?
 
> You need to do 2 things:
>
> 1) Run 2to3 on the shell not the python interpreter.
> 2) Learn some basic UNIX.
>
> cheers
> James


I tried to run it on the command prompt (I use Windows XP) but it
doesn't work either.

I opened the command prompt:

C:\Documents and Settings\User>

Then I typed '$ 2to3 testscript.py':

C:\Documents and Settings\User>$ 2to3.py testscript.py

But then this appears:

C:\Documents and Settings\User>$ 2to3.py testscript.py
'$' is not recognized as an internal or external command,
operable program or batch file.

Anyway I'll try some UNIX. Thanks.

James Mills 01-15-2009 06:43 AM

Re: 2to3 Help?
 
On Thu, Jan 15, 2009 at 4:32 PM, <marco.m.petersen@gmail.com> wrote:
> I tried to run it on the command prompt (I use Windows XP) but it
> doesn't work either.


I did not realize you were using WIndows :)
Normally most shells in the UNIX/Linux world
start with a '$'.

> I opened the command prompt:
>
> C:\Documents and Settings\User>
>
> Then I typed '$ 2to3 testscript.py':
>
> C:\Documents and Settings\User>$ 2to3.py testscript.py
>
> But then this appears:
>
> C:\Documents and Settings\User>$ 2to3.py testscript.py
> '$' is not recognized as an internal or external command,
> operable program or batch file.


Your problem is, you are treating the '$' (most likely
copied/pasted from readings on the web) as part
of what you need to enter into the command prompt.

'$' is (like I said above) normally part of most commonly
configured shells (eg: Bash).

You need to just enter:

2to3 testscript.py

> Anyway I'll try some UNIX. Thanks.


That is a good idea :) Windows teaches you nothing!

cheers
James

alex23 01-15-2009 06:46 AM

Re: 2to3 Help?
 
On Jan 15, 4:32*pm, marco.m.peter...@gmail.com wrote:
> I tried to run it on the command prompt (I use Windows XP) but it
> doesn't work either.
> '$' is not recognized as an internal or external command,
> operable program or batch file.


'$' is used in the instructions to denote a command prompt. You're not
supposed to type it :)

In your case '$' == 'C:\Documents and Settings\User>'; just type
'2to3.py testscript.py' and it should work (assuming it's location is
in your PATH and you have the right handlers set up to launch it)


marco.m.petersen@gmail.com 01-15-2009 06:52 AM

Re: 2to3 Help?
 
Oh okay. I don't think my Python installation is in PATH yet. I'll try
to add it then.

alex23 01-15-2009 07:02 AM

Re: 2to3 Help?
 
On Jan 15, 4:52*pm, marco.m.peter...@gmail.com wrote:
> Oh okay. I don't think my Python installation is in PATH yet. I'll try
> to add it then.


I don't yet have 3.0 installed, but my guess is you'll also need to
have 'C:\Python30\Scripts' in your path as well. I'm assuming that's
where it resides, so check first.

marco.m.petersen@gmail.com 01-15-2009 07:13 AM

Re: 2to3 Help?
 
> I don't yet have 3.0 installed, but my guess is you'll also need to
> have 'C:\Python30\Scripts' in your path as well. I'm assuming that's
> where it resides, so check first.


Its in C:\Python30\Tools\Scripts.

Anyway it now works.

C:\Documents and Settings\User>python C:\Python30\Tools\Scripts
\2to3.py C:\Python30\testscript.py

Thanks a lot alex23.


All times are GMT. The time now is 02:25 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.