How to Check Python Version in Colab?

4.5/5 - (2 votes)

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:

Click to run code in Colab Jupyter Notebook

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

Summary: To check the Python version in your Jupyter Colab Notebook, do any of the following:

  • !python ‐‐version
  • import sys; print(sys.version)

Thanks for reading the whole article, feel free to join our community of like-minded and ambitious coders — and download our Python cheat sheets!