Migrating From Python 2 to 3

Why should you migrate?

Because Python 2 is no longer supported! Support for Python 2 should have stopped at the beginning of 2020. The last major 2.7.x release was in April 2020. All development has ceased for Python 2. This means there will be no security updates.

Many package maintainers have migrated to Python 3. Some still support Python 2, while others already dropped support. From here on, most packages will gradually stop supporting it. Python 3.0 was released on December 3, 2008. So yeah, we’ve all had plenty of time to migrate. If you still haven’t, you should make it a top priority right now. At the max, you should be running Python 3 before the end of 2020. Otherwise, you will be at risk of vulnerabilities, non-functioning software, etc.

Besides security and support, Python 3 has many benefits; the language has improved for the better, as can be read on our page about Python 3’s advantages.

Can you have python 2 and 3 at the same time?

If you really need to run Python 2 for legacy codebases, you can run it alongside Python 3 easily.


To run Python 2 and 3 at the same time on Windows, you need to install both versions of Python. After that, I recommend using the Python launcher. This launcher can be invoked with the py command. It will inspect your script for a so-called shebang that specifies either Python 2 or Python 3.

Alternatively, you can explicitly pick a version: use py -3 yourscript.py to launch your script with Python 3, or py -2 yourscript.py to launch it with Python 2.


If you want to have Python 2 and Python 3 at the same time on Linux, you need to install both. Python 2 can often be started with the python command, while Python 3 is started with the python3 command.

Get certified with our courses

Learn Python properly through small, easy-to-digest lessons, progress tracking, quizzes to test your knowledge, and practice sessions. Each course will earn you a downloadable course certificate.

Related articles

Leave a Comment