How to use 2to3 tool in windows?
Asked Answered
R

2

24

I tried to modify the sintax using 2to3 tool by running command

python C:\Python32\Tools\scripts\2to3.py neo4j.py

and got the output

enter image description here

When opening neo4j.py however I noticed there hasn't been anything changed. Below is the block of code where changes (accoridng to output) should be made:

try:
    import json
except ImportError:
    import simplejson as json
try:
    from urllib.parse import quote
except ImportError:
    from urllib import quote
try:
    from . import rest, batch, cypher
except ImportError:
    import rest, batch, cypher
except ValueError:
    import rest, batch, cypher

import logging
logger = logging.getLogger(__name__)

Does anyone know how to use 2to3 tool properly in order to port/change the code to v3.2?

Roddie answered 17/6, 2012 at 11:42 Comment(2)
The new version (pypi.python.org/pypi/py2neo) of py2neo claims Python 3 compatibility out of the box.Ingratiate
I tried this version but it doesn't workRoddie
H
49

You have to use the -w flag to actually write the changes:

python C:\Python32\Tools\scripts\2to3.py -w neo4j.py

See the 2to3.py documentation.

Halflength answered 17/6, 2012 at 11:45 Comment(2)
I just get invalis sytax on the letter C:Corrasion
@Ifyoudonotknow-justGIS What do you mean?Practise
N
4

As an addition to the accepted answer,

Copy this line to C:\python32\Scripts\2to3.bat:

@python %~dp0..\tools\scripts\2to3.py %*

After that you'll be able to use

2to3 -w neo4j.py
Neelyneeoma answered 8/12, 2016 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.