Let’s take a look: # Checking the Python Version Using the sys libraryīecause this returns a multi-line string, it’s not immediately accessible. This returns the same information as the -VV command shown above. One of the simplest ways is to simply print out the. The sys library provides a number of different ways in which you can access the version of Python you’re running. How to Check Your Python Version in a Script Using sys In the next sections, you’ll learn how to check the version of Python your code is running in your script using the sys and platform libraries. The table below breaks down the different commands to run on macOS and Linux to get the version of Python: Commandĭifferent commands to check your Python version on macOS and Linux Because of this, you may need to run python3 instead, to refer to that version of Python. Open Spotlight by hitting command + spaceīecause some versions of macOS come with Python 2 installed by default, it’s likely that the python command may refer to Python 2.On macOS, this can be accomplished by following the steps below: In macOS and Linux you can use the Terminal application to check your version of Python. How to Check Your Python Version on macOS / Linux In the next section, you’ll learn how to check your Python version on macOS or Linux. In order to do this, you can run the following steps:Ĭheck the table below for the different types of commands you can run in order to check your version of Pyhton on Windows 7: Commandĭifferent commands to check your Python version on Windows 7 On Windows 7 and earlier, you can use the command prompt to check your Python version. Python 3.8.5 (default, Sep 4 2020, 02:22:02)ĭifferent commands to check your Python version on Windows 10 How to Check Your Python Version on Windows 7 Shortened information about Python versionĮxtended information about the Python version Once the PowerShell is open you can access the Python version your interpreter is running by writing the commands shown below. In order to access the PowerShell, simply use the following steps: In Windows 10, we can use the PowerShell to check the version of Python that we are running. How to Check Your Python Version on Windows 10 Over the following sections, you’ll learn how to check your Python version using Windows 10, Windows 7, macOS, and Linux. Because accessing the command line prompt or terminal varies from system to system, this part of the tutorial is split across the different operating systems available to you. To check the version that your Python interpreter is running we can use a version command on the python command. How to Check Your Python Version in a Script Using platform.How to Check Your Python Version in a Script Using sys.
0 Comments
Leave a Reply. |