Skip to content
Home » Python Interpreter – Version, Path and Platform Check

Python Interpreter – Version, Path and Platform Check

Spread the love

Today we’ll see how to programmatically check a couple of things. In particular, we’ll be checking the version of the Python interpreter you’re using, the absolute path to the executable binary of the Python interpreter and the platform on which Python is running.

python interpreter

We’ll need the sys module, so let’s import it:

import sys

Now we can use the version static object to retrieve the version of the interpreter as a string:

>>> sys.version
'3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]'

We can also use the version_info static object to get version information as a named tuple.

>>> sys.version_info
sys.version_info(major=3, minor=7, micro=0, releaselevel='final', serial=0)

If we want, we can also check any particular element of the version, like the major version or the minor version for example:

>>> sys.version_info.major
3

Your Panda3D Magazine

Make Awesome Games and Other 3D Apps

with Panda3D and Blender using Python.

Cool stuff, easy to follow articles.

Get the magazine here (PDF).

We use the executable static object to check the absolute path of the executable binary of the Python interpreter:

>>> sys.executable
'C:\\Users\\user-1\\Source\\Repos\\Code\\Code\\env\\Scripts\\python.exe'

And here’s how we can check the platform on which Python is running:

>>> sys.platform
'win32'

Python Jumpstart Course

Learn the basics of Python, including OOP.

with lots of exercises, easy to follow

The course is available on Udemy.

Blender Jumpstart Course

Learn the basics of 3D modeling in Blender.

step-by-step, easy to follow, visually rich

The course is available on Udemy and on Skillshare.

Here’s the video version of the article:


Spread the love

Leave a Reply