Hey folks,
I’ve started working on a script to automate image uploads and transformations using Cloudinary. I’m trying to install some Python libraries, but I keep running into compatibility issues.
Before I go further, can someone explain how to check Python version on my system? I want to make sure I’m using the right version, especially since some features or packages may not work on older ones.
Appreciate any help!
Whether you’re working with image libraries like Pillow, automation tools, or APIs, knowing what Python version you’re using (or what you need) is essential.
Let’s walk through the various ways to check your Python version, from the command line to inside your code.
The most straightforward method is via your system’s command line.
python --version
or:
python -V
Output might be:
Python 3.11.2
If you’re using python3 (which you should be), run:
python3 --version
Output:
Python 3.10.13
- Many modern libraries (e.g., Cloudinary SDK, OpenCV, Pillow) require Python 3.6+.
- Syntax changes in Python 3.8+ can affect list handling, f-strings, and more.
- Python 2 reached end of life at the beginning of 2020, and is no longer supported.
If you’re writing a Python script and want to confirm the version programmatically:
import sys
print(sys.version)
# output: 3.11.2 (main, Feb 5 2024, 15:15:21) [GCC 11.2.0]
Code language: CSS (css)
To get just the version number:
print(sys.version_info)
This is especially useful when you’re distributing a script or package and want to alert the user if their version is too old.
Here’s a practical example: you’re writing a script that uses Pillow for image manipulation. Let’s say you want to ensure the script only runs on Python 3.7 or newer:
import sys
if sys.version_info < (3, 7):
raise Exception("This script requires Python 3.7 or higher. Please update your Python version.")
# Rest of your image processing code
print("Python version is compatible. Proceeding with upload...")
Code language: PHP (php)
If you’re using a virtual environment (which you should!), activate it and then check:
python --version
This confirms the version of Python in your virtual environment, not the system-wide version.
If you have multiple versions installed, try:
where python
(on Windows) or:
which -a python
(on Linux/macOS) to see paths of different Python versions.
You might see:
/usr/bin/python
/usr/local/bin/python3.11
This is helpful if you’ve installed Python via tools like Homebrew, Anaconda, or pyenv.
import platform
print(platform.python_version())
# Output: 3.10.6
Code language: CSS (css)
You can also retrieve system architecture and OS info, which is useful for debugging cloud deployments or server setups. Then if you need to update your Python version, try checking out our Q&A.
If you want to validate the version and proceed with an image upload:
import sys
import cloudinary.uploader
if sys.version_info < (3, 7):
raise Exception("Python 3.7+ is required.")
upload_result = cloudinary.uploader.upload("image.jpg", public_id="version_check_test")
print("Upload successful:", upload_result["secure_url"])
Code language: JavaScript (javascript)
Task | Command or Code |
Check version in terminal | python --version |
Check version in script | import sys; print(sys.version) |
Check major.minor.micro | sys.version_info |
Get version as string | platform.python_version() |
Verify virtualenv version | python --version (after activation) |
Require minimum version | if sys.version_info < (3, 7): raise ... |
Knowing how to check Python version is essential for running reliable scripts, working with APIs like Cloudinary, and avoiding nasty bugs due to syntax or package issues.
Whether you’re writing simple scripts or deploying production workflows, this should be one of the first steps before installing dependencies or building out features.