Recommended Free Tools
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Print pygame.version.ver to see the Pygame release your program imported. To identify where it came from, also print Python’s executable path and the imported package path: those help reveal when a terminal, editor, notebook, or launched app is using a different Python environment than expected.
Print the Pygame version and installation paths
Run this after importing Pygame. The release string and comparison tuple describe Pygame; the paths help you identify which Python interpreter and package your process resolved.
import sys
import pygame
print("Python executable:", sys.executable)
print("Pygame imported from:", pygame.__file__)
print("Pygame version:", pygame.version.ver)
print("Pygame comparable version:", pygame.version.vernum)
The Pygame reference says its version module is automatically imported and can be used to check which version was imported. pygame.version.ver is the version string; pygame.version.vernum is an integer tuple intended for version comparisons. Pygame reference
sys.executable and pygame.__file__ are useful diagnostic context: compare them across the places you run the program. If the version is unexpected, first check whether the executable and package path match the Python environment where you installed Pygame. These paths are practical debugging clues, not guarantees that every environment reports them identically.
#1 Best Overall
Compare versions without string-ordering mistakes
Use vernum for a minimum-version check rather than comparing version strings lexicographically. The official reference demonstrates comparing the tuple against a threshold:
if pygame.version.vernum < (2, 0, 0):
raise RuntimeError("This project requires Pygame 2.0.0 or later")
Adjust the threshold to the version your project actually requires. A version value tells you what was imported; it does not, by itself, establish whether that release is the newest available.
Rank #2
Check SDL separately when compatibility matters
SDL has its own version number, separate from Pygame’s release. Add these lines when diagnosing SDL compatibility:
print("SDL linked version:", pygame.get_sdl_version())
print("SDL compiled-against version:", pygame.get_sdl_version(linked=False))
By default, pygame.get_sdl_version() returns the version of the SDL library Pygame is linked against at runtime. Passing linked=False returns the SDL version Pygame was compiled against. Label the value you report: the two readings answer different questions. The linked argument was added in Pygame 2.2.0, so code using it needs to account for older releases. Pygame reference
If Pygame imports but a module does not work
A successful import pygame does not guarantee that every optional Pygame submodule is available. The reference notes that unavailable optional modules may be represented by placeholders. Check the specific module you need, and inspect initialization results rather than treating the top-level import as proof that all modules initialized.
pygame.init() returns a pair of counts: the number of modules initialized successfully and the number that failed. Individual modules can also be initialized separately. Use the result to investigate initialization problems; it is not a substitute for checking that a particular optional module exists and works in your setup. Pygame reference
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

