Check your Python version from the command line
The fastest way to find out which Python version you have is to open your terminal or command prompt and run a single command. On Windows, Mac, or Linux, type python --version or python3 --version and press Enter. The system will print the version number when ready.
If you have both Python 2 and Python 3 installed, you may need to try both commands. python often points to Python 2 (which is no longer maintained), while python3 points to the current version. Most modern projects use Python 3, so if only one command works, it is probably the one you need.
On Windows, if the command is not recognized, Python may not be in your system path. You can still find the version by opening the Python interpreter directly — search for "Python" in your Start menu, click the process, and it will display the version number in the first line of output.
Key Takeaways
- Run python --version or python3 --version in your terminal to see your Python version when ready.
- If you have both Python 2 and Python 3, try both commands because they may point to different installations.
- On Windows, you can open the Python process directly from your Start menu to see the version if the command line does not work.
- Knowing your version matters because some code and libraries only work with Python 3, and Python 2 is no longer updated.
Check the version inside a Python script
If you are already writing Python code, you can check the version from within a script using the sys module. Add these lines to your code:
import sys print(sys.version)
This will print the full version string, including the build number and compiler information. If you only want the version number itself, use sys.version_info instead, which breaks the version into separate parts you can work with individually.
Why your Python version matters
Different Python versions have different features and syntax rules. Code written for Python 3.8 might not run on Python 3.6, and Python 2 code will fail on Python 3 without changes. When you read a project from GitHub or install a package with pip, the documentation usually says which Python versions it supports.
Checking your version before you start saves time. If a project requires Python 3.9 or newer and you have Python 3.7, you will need to upgrade before the code will run. Some projects list their requirements in a file called requirements.txt or setup.py, which you can read to see what version you need.
Update Python if you have an old version
If your check shows Python 2 or an old Python 3 version, you may want to upgrade. On Mac, the easiest route is Homebrew: run brew install python3 in your terminal. On Windows, read the installer from python.org and run it. On Linux, use your package manager — for Ubuntu or Debian, run sudo apt-get install python3.
After you install a new version, run the version check command again to confirm the upgrade worked. Your old Python installation will usually stay in place, so both versions can coexist if you need them for different projects.
Check which Python your IDE or text editor is using
If you write code in an editor like Visual Studio Code or PyCharm, the editor may use a different Python version than the one you have as default. In Visual Studio Code, click the Python version number in the bottom right corner of the window to see which interpreter is active and switch to a different one if needed.
In PyCharm, go to PyCharm > Preferences (on Mac) or File > Settings (on Windows and Linux), then navigate to Project > Python Interpreter. You will see which version is selected and can change it to match the version your project needs.
Verify the right version is installed for your project
Some projects use a file called .python-version or pyproject.toml to specify exactly which Python version they need. If you clone a project and see one of these files, open it in a text editor and look for the version number. Then check your own version against what the file says.
If you use virtual environments (a common practice for keeping different projects separate), each environment can have its own Python version. When you set up a virtual environment, the python --version command will show the version for that environment, not your system default.
Frequently Asked Questions
What is the difference between python and python3?
On most systems, python points to Python 2 (which stopped being updated in 2020) and python3 points to Python 3 (the current version). If you only have Python 3 installed, python may not work at all. Always use python3 unless you are working with legacy code that requires Python 2.
Can I have multiple Python versions installed at the same time?
Yes. You can install Python 2 and Python 3 side by side, or multiple versions of Python 3. The python and python3 commands will point to different installations. Use virtual environments to keep projects separate and avoid conflicts between versions.
Why does my Python version command not work?
Python may not be in your system path, which means your terminal cannot find it. On Windows, reinstall Python and check the box that says "Add Python to PATH" during installation. On Mac and Linux, try python3 instead of python, or check that Python is installed in a location your terminal can access.
Do I need to update Python if I have an older version?
It depends on the project. Check the project's documentation or requirements.txt file to see which versions it supports. If your version is older than what is required, you will need to upgrade. If the project works with your current version, you do not need to update.