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.

Please share this article with others!

Python Courses

Are you enjoying this free tutorial? Please also have a look at my premium courses. They offer a superior user experience with small, easy-to-digest lessons and topics, progress tracking, quizzes to test your knowledge, and practice sessions. Each course will earn you a downloadable course certificate.

The Python Fundamentals Course For Beginners
Now for $29 (from $59)

Python Fundamentals I is a course for beginners that will get you started with Python in no time. Learn all the essentials, test your progress with quizzes and assignments, and bring it all together with the final course project!

Python Course for Beginners

Modules, Packages, And Virtual Environments
Now for $29 (from $59)

Python Fundamentals II covers creating your own modules and packages, using virtual environments and Python package managers to make your life as a programmer easier. Advance your productivity as a Python programmer!

Python Fundamentals 2

Leave a Comment

Share to...