20
Convert python 2 to python 3 [In 1 Single Click]
After 1 January 2020 many companies and individuals are worried about their Python 2 code because Python’s organization stops support for Python 2, and the new development era was moving to python3 to solve this problem. There. They are few packages developed over time, one of them is official and extremely powerful.
- 2to3 (Offical, recommended)
- Python Future + Futurize
- Six + Modernize
Now at this point, you definitely thinking well, what’s the difference between, 2to3, Python Future + Futurize, and Six + Modernize.
Here’s your answer!
Automated tools for PY2 to PY3 conversion/compatibility?
This can be very easy if you use any of the above libraries (do not forget to make sure the compatibility)
There are two approaches for converting Python 2 to python 3.
There is a simple tool for converting python 2 to python 3.
you can use a web application to convert python 2 to 3.
This tool is:
- 100% FREE
- Compatible with All versions of Python
- Actively maintained
We can convert Python2 scripts to Python3 scripts by using the 2to3 module. It changes Python2 syntax to Python3 syntax. We can change all the files in a particular folder from python2 to python3.
Open your terminal or CMD depend on whatever you are using Windows or Linux.
Navigate to the directory where your python file(s) is/are located. (of course, using the “cd” command)
As usable, use pip to install 2to3, use can use any other library as well, I like 2to3
Commnd: pip install 2to3
Excute: 2to3 [file or folder] -w
20