Search code examples
pythonpydevpython-2to3

Applying 2to3 in PyDev project in Eclipse does not affect any changes to files


I opened a Python 2 project in PyDev on Eclipse with a Python3 interpreter installed, so I get errors in certain places.

The project's context menu has a PyDev -> "Apply 2to3" option. When I select it, I see diff output in my console but the .py files in the project are not changed. I don't see any obvious way to apply the diff output to make those changes.

Shouldn't "Apply 2to3" perform changes to the files and leave the project ready to compile under Python 3?


Solution

  • You have to enter the parameters for 2to3 to do that...

    I just saw that the dialog is currently horrible (it doesn't show the full text -- back then the text from 2to3 was probably small, but now that it's big it doesn't fit on the dialog space very well and the content is cropped to what's visible -- just fixed it: https://github.com/fabioz/Pydev/commit/fb0aa9d28c15e7deeb3aa229b0ad66146802d9e4).

    Now, to answer your question, at the dialog that opens you need to pass -w to write the files creating a backup file or -w -n if you want to write the files but don't want to keep backup files -- which I recommend if your source code is already under source control ;)