17

How do I go about programmatically getting the Blender version number?

Example: If I am running Blender 2.76, how would I get the version number from the python console?

ideasman42
  • 47,387
  • 10
  • 141
  • 223
Greg
  • 623
  • 1
  • 5
  • 9
  • Just out of curiosity, why do you want to do that with python? It seems much easier and faster to me to simply click on the splash screen. – jng224 Jul 23 '20 at 18:42

2 Answers2

32

bpy.app.version_string

Test using the python console:

>>> bpy.app.version_string
'2.83.2'

Usage within a script file:

import bpy
print(bpy.app.version_string)

which will print the actual version to the system console window:

2.83.2

bpy.app.version

If you're looking to compare version numbers, it's easier to do this using bpy.app.version which will always be a tuple of 3 ints, (major, minor, subversion), eg: (2, 76, 0)

So you can compare the version number with regular comparison.

if (2, 76, 0) > bpy.app.version:
    print("Your Blender version is too old!")
brockmann
  • 12,613
  • 4
  • 50
  • 93
Greg
  • 623
  • 1
  • 5
  • 9
0

Either open up a Text Editor area or just switch the Workspace to Scripting. Create a new document with the following contents and click run script or just press AltP:

import bpy

print(bpy.app.version_string)

In the main menu bar go to Window > Toggle System Console to display the requested blender version in Blender's Console Window.

brockmann
  • 12,613
  • 4
  • 50
  • 93
  • 4
    How this is different to the existing answer? – brockmann Jul 23 '20 at 12:54
  • 2
    Would point out the OP asked for python console code, no print necessary. Those of us using Linux or Mac versions of blender do not have the toggle system console menu item. Agree with @brockmann comment, this adds very little in way of new information. – batFINGER Jul 23 '20 at 13:59