{"id":48373,"date":"2024-06-10T12:30:00","date_gmt":"2024-06-10T17:30:00","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=48373"},"modified":"2024-04-29T02:41:29","modified_gmt":"2024-04-29T07:41:29","slug":"how-to-check-python-version-on-linux","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/","title":{"rendered":"How to Check Python Version on Linux"},"content":{"rendered":"
<\/div>\n
\"How<\/figure>\n\n\n\n

<\/p>\n\n\n\n

In this guide, we’ll walk you through various methods to help you check Python version on Linux. Python<\/a> has become one of the most popular programming languages worldwide, because of its simplicity and the wide range of areas in which it is used such as web frameworks, software development, data analysis, and task automation. However, ensuring you have the correct version of Python installed is crucial to check for compatibility and if you are running the latest version if you are starting a new project.<\/p>\n\n\n\n\n\n\n\n

Check Python Version on Linux Using Command Line<\/h2>\n\n\n\n


The simplest and most common way to check the Python version is through the command line or terminal. Here’s how you can do it:
<\/p>\n\n\n\n

First, you will need to log in to your Server via SSH:<\/p>\n\n\n\n

# ssh jeff@IP_Address -p Port_number<\/code><\/pre>\n\n\n\n


You will need to replace \u2018IP_Address\u2019 and \u2018Port_number\u2019 with your server\u2019s respective IP address and SSH port number. <\/p>\n\n\n\n

For the older Python version, for Python 2 installations, you can type the following command in the terminal:<\/p>\n\n\n\n

python --version<\/code><\/pre>\n\n\n\n

You can also check the Python 2 version with the command:<\/p>\n\n\n\n

python -V<\/code><\/pre>\n\n\n\n

This will display the installed Python version, such as Python 2.7.18<\/strong>.<\/p>\n\n\n\n

To check the version the installed Python3 version, open your terminal or command prompt and type the following command:<\/p>\n\n\n\n

python3 --version<\/code><\/pre>\n\n\n\n

or<\/p>\n\n\n\n

python3 -V<\/code><\/pre>\n\n\n\n


This will display the installed Python 3 version, such as Python 3.8.5.<\/p>\n\n\n\n

Checking Python version using the Python Interpreter<\/h2>\n\n\n\n


Another way to check the Python version is by using the Python interpreter itself also known as the Python shell. Here’s how:<\/p>\n\n\n\n

Open your terminal or command prompt and for Python 2 and Python 3 both, type python and click enter.
Once in the Python interpreter, import the sys module with:<\/p>\n\n\n\n

import sys<\/code><\/pre>\n\n\n\n

and then enter the following command:<\/p>\n\n\n\n

print(sys.version)<\/code><\/pre>\n\n\n\n

This will print detailed information about the Python version, including the build number and date.<\/p>\n\n\n\n

If you want to check the Python version within a Python script, you can use the following method:<\/p>\n\n\n\n

import platform<\/code><\/pre>\n\n\n\n

Import the platform module and then print the Python version using the command or line:<\/p>\n\n\n\n

print(platform.python_version())<\/code><\/pre>\n\n\n\n

This will output the Python version installed on your system.<\/p>\n\n\n\n


Knowing how to check the Python version is essential for ensuring compatibility with libraries, frameworks, and applications. By following the methods outlined in this guide, you can easily determine the Python version installed on your machine, whether you’re using the command line, Python interpreter, or programmatically within a script. <\/p>\n\n\n\n

Keeping your Python environment up-to-date is crucial for staying current with the latest features, security patches, and improvements in the language. If you like this post, please share it with your friends if they need help on how to check the Python version on their system.<\/p>\n","protected":false},"excerpt":{"rendered":"

In this guide, we’ll walk you through various methods to help you check Python version on Linux. Python has become … <\/p>\n

Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":48425,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2071],"tags":[2153,27,155],"yoast_head":"\nHow to Check Python Version on Linux - RoseHosting<\/title>\n<meta name=\"description\" content=\"Learn how to check what Python version you have on Linux using Command Line or the Python Interpreter using our easy-to-follow guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Check Python Version on Linux - RoseHosting\" \/>\n<meta property=\"og:description\" content=\"Learn how to check what Python version you have on Linux using Command Line or the Python Interpreter using our easy-to-follow guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-10T17:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T07:41:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"576\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Check Python Version on Linux\",\"datePublished\":\"2024-06-10T17:30:00+00:00\",\"dateModified\":\"2024-04-29T07:41:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\"},\"wordCount\":443,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp\",\"keywords\":[\"how to\",\"Linux\",\"python\"],\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\",\"name\":\"How to Check Python Version on Linux - RoseHosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp\",\"datePublished\":\"2024-06-10T17:30:00+00:00\",\"dateModified\":\"2024-04-29T07:41:29+00:00\",\"description\":\"Learn how to check what Python version you have on Linux using Command Line or the Python Interpreter using our easy-to-follow guide.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp\",\"contentUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp\",\"width\":1024,\"height\":576,\"caption\":\"How to Check Python Version on Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.rosehosting.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Check Python Version on Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#website\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/\",\"name\":\"RoseHosting\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/RoseHosting\",\"https:\/\/x.com\/rosehosting\",\"https:\/\/www.linkedin.com\/in\/rosehosting\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\/\/www.rosehosting.com\",\"https:\/\/www.facebook.com\/rosehosting.helpdesk\"],\"url\":\"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Check Python Version on Linux - RoseHosting","description":"Learn how to check what Python version you have on Linux using Command Line or the Python Interpreter using our easy-to-follow guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Check Python Version on Linux - RoseHosting","og_description":"Learn how to check what Python version you have on Linux using Command Line or the Python Interpreter using our easy-to-follow guide.","og_url":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2024-06-10T17:30:00+00:00","article_modified_time":"2024-04-29T07:41:29+00:00","og_image":[{"width":1024,"height":576,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp","type":"image\/webp"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Check Python Version on Linux","datePublished":"2024-06-10T17:30:00+00:00","dateModified":"2024-04-29T07:41:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/"},"wordCount":443,"commentCount":0,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp","keywords":["how to","Linux","python"],"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/","url":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/","name":"How to Check Python Version on Linux - RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp","datePublished":"2024-06-10T17:30:00+00:00","dateModified":"2024-04-29T07:41:29+00:00","description":"Learn how to check what Python version you have on Linux using Command Line or the Python Interpreter using our easy-to-follow guide.","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2024\/06\/how-to-check-python-version-on-linux.webp","width":1024,"height":576,"caption":"How to Check Python Version on Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-check-python-version-on-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Check Python Version on Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"]},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/48373"}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=48373"}],"version-history":[{"count":4,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/48373\/revisions"}],"predecessor-version":[{"id":48449,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/48373\/revisions\/48449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/48425"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=48373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=48373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=48373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}