Skip to article frontmatterSkip to article content

Want to Set the Version in Python?

Some people prefer to define their version in a __version__ global.

__version__ = "1.0.0"

This lets you use the version number in your code:

def show_package_info():
    print(f"This package has version {__version__}")

It’s possible to get the installed version another way:

import importlib.metadata
importlib.metadata.version("arrow-to-knee")

But this can be “slow” for some applications.