How To Quickly Check Python Version In PyCharm

How can you check the version of Python you are using in PyCharm?

There are three ways to check the version of your Python interpreter being used in PyCharm: 1. check in the Settings section; 2. open a terminal prompt in your PyCharm project; 3. open the Python Console window in your Python project.

Let’s look at each of these in a little more detail:

How To Check Python Version Using PyCharm Settings

To check the version of Python being used in your PyCharm environment, simply click on the PyCharm menu item in the top left of your screen, and then click on Preferences.

From the Preferences window find an option that starts with Project: and then has the name of your project. Open that branch and you should see two options underneath: Python Interpreter and Project Structure . You want to click on the option Python Interpreter .

When you do you should see something like this:

The Python Interpreter section in your Project shows you the version of Python being used

As you can see from this section in PyCharm you should easily be able to spot the version of Python being used by your project.

How To Check Python Version Using Terminal

In PyCharm when you open the terminal window you should see the terminal contain the virtual environment of your project.

For example, when opening a normal terminal prompt on the Mac you would see something like this:

rds@Ryans-MacBook-Pro-2 ~ % 

But when opening the terminal window in PyCharm you should see something a little different, perhaps something like this:

(venv) rds@Ryans-MacBook-Pro-2 %

The word in the parentheses might be different (venv) but the prompt is to show you that you are running a Python interpreter according to the project’s settings (as shown above) and therefore may not necessarily be the default interpreter when running Python code on your machine.

This is the flexibility you have when using Python, you can create different projects and use different Python versions.

Once you’ve loaded terminal within PyCharm to check the version of the environment enter the following command:

(venv) rds@Ryans-MacBook-Pro-2 % python --version

As you can see above from what I see on the terminal prompt you need to enter the command python --version .

When you enter this command you should see the following result:

(venv) rds@Ryans-MacBook-Pro-2 % python --version
Python 3.8.9

This result tells you what version of Python is running from the terminal window within PyCharm.

Checking Python Version From Mac Terminal

You can check your Python version from your Mac terminal using the same command above.

If you open up a new terminal window you might see something like this:

Last login: Mon Dec 13 08:39:57 on console
rds@Ryans-MacBook-Pro-2 ~ %

To check the default Python version your Mac is using you can run the same command as done above:

rds@Ryans-MacBook-Pro-2 ~ % python --version
Python 2.7.18

This means whenever I run the command python from my Mac’s terminal window it will actually run the Python 2.7 version.

What Version Of Python 3 Is On My Mac?

To check what default version of Python3 is used on your Mac, run the same command above but instead use the syntax python3 instead of just python , like so:

rds@Ryans-MacBook-Pro-2 ~ % python --version
Python 3.9.7

Therefore, depending on your Python scripts and how you want to run them from your Mac be mindful of whether to prefix your script with either python or python3 depending on which version you’ve written your code in.

How To Check Python Version Using Python Console

Another option available to check the version of your Python interpreter within PyCharm is from the Python Console window.

Upon clicking on the Python Console window you should see the familiar Python REPL command:

Python Console

>>>

From the REPL you want to import the sys module and then run sys.version like so:

Python Console

>>> import sys
>>> sys.version
'3.8.9 (default, Aug  3 2021, 19:21:54) \n[Clang 13.0.0 (clang-1300.0.29.3)]'

As you can see by running sys.version you are given the output of the Python interpreter being used in your PyCharm project.

Summary

To find the version of Python you are using in your PyCharm project navigate either to PyCharm’s Preferences and look for the Python Interpreter section under your Project, or from the terminal window in PyCharm within your Python environment enter python --version , or from the Python Console window import the sys module and then run the command sys.version .

Each method listed above will report the version being used with the Preferences option providing the version number according to its first point (i.e. 3 .8 ), the second option when using the terminal window providing the second point (i.e. 3.8 .9 ) and the final option providing everything about the version including the time the version was released (i.e. 3.8.9 (default, Aug 3 2021, 19:21:54) ).

Photo of author
Ryan Sheehy
Ryan has been dabbling in code since the late '90s when he cut his teeth exploring VBA in Excel. Having his eyes opened with the potential of automating repetitive tasks, he expanded to Python and then moved over to scripting languages such as HTML, CSS, Javascript and PHP.