To check your Python version in Google’s Colab, type
!python ‐‐version using the exclamation mark
! operator in your Jupyter Notebook cell and click on the “Run” icon. After a couple of seconds an output like Python 3.9 will appear, depending on the version you’ve installed.
In Jupyter notebooks, the exclamation mark
! executes commands from the underlying operating system.
💡 Recommended Tutorial: What’s the Meaning of the Exclamation Mark in a Jupyter Notebook?
Feel free to try it yourself in our Colab Jupyter Notebook created for this tutorial:
By the way, there are some alternatives to checking your Python version in your script. I’d recommend you check out our deep dive on the Finxter blog as well.
For example, the following approach using the
sys library can also help you check out the version of your Python in Colab:
import sys print(sys.version)
Summary: To check the Python version in your Jupyter Colab Notebook, do any of the following:
import sys; print(sys.version)
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.