17 Resources to transition from Python 2 to Python 3

How to transition from Python 2 to Python 3

Now that Python 2 is sunsetting on January 1, 2020, it's mandatory that some planning goes into the smooth transitioning from Python 2 to Python 3. But what should you consider while planning this transition, where to find the resources?

How long do you have?
That's exactly what the Python Clock is here to tell you. And as of writing this article, you have around 2 months to ensure a smooth transition.

Is transitioning mandatory?
No. But if on a later date a potential security threat is found in Python 2, or in software written in Python 2, then most volunteers will not help fix them. If you need any other help with Python 2 software, then many volunteers will not help you, and over time fewer and fewer volunteers will be able to help you. You will lose the opportunity to use good tools because they will only run on Python 3, and you will slow down people who depend on you and work with you. And even though these problems might not become evident right away, they would definitely grow over time.

You can try the Python 3 Readiness website which shows Python 3 support for the 360 most downloaded packages on PyPI. As of the time of writing of this article, all 360 packages support Python 3.

How to port Python 2 code to Python 3?
The Python community has an excellent article on this. It gives a detailed description on how to port your Python 2 code to Python 3. You can also read about porting extension modules from Python 2 to Python 3.

Please also read the Python 3 Statement Practicalities for advice on sunsetting your Python 2 code.

If you are not sure whether the software you are using is built upon Python 2, ask your vendor. If you have Python developers or system administrators on your payroll, ask them. If you don't have vendors or technical staff, then use "Can I Use Python 3?" to find out which tools you need to upgrade to Python 3.

Where to find help?
There is a detailed Q&A list by Nick Coghlan. There is also a Python program called 2to3, this reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. In Pycharm IDE, click terminal in status bar Now, and you will be in shell command, in the root of your project. There, type the following command (to convert

You can also try the online Python 2 to Python 3 converter if you have smaller programs. Here's a Cheat Sheet on how to write Python 2-3 compatible code by Ed Schofield. You can download the PDF version, and visit their page here.

You can also try the Python Crash Course: A Hands-On, Project-Based Introduction to Programming book, it is one of the best books that dispenses with the tedious, unnecessary information that can get in the way of learning how to program, instead it chooses to provide a foundation in general programming concepts, Python fundamentals, and problem solving. Three real world projects in the second part of the book allow readers to apply their knowledge in useful ways. You can also try the free training from Microsoft.

If you are willing to pay for extended support, get in touch with one of these vendors. You can also pay to hire someone who would help you through this transition phase, for this you can post on the Python job board. If you need free help from volunteers, look at this help page.

And finally, don't forget to subscribe to our feed to keep yourself updated of any such news in the future.