{"id":1438,"date":"2022-04-30T09:20:50","date_gmt":"2022-04-30T06:20:50","guid":{"rendered":"http:\/\/leonidassavvides.com\/blog\/?p=1438"},"modified":"2022-04-30T09:20:50","modified_gmt":"2022-04-30T06:20:50","slug":"check-python-version-from-command-line-and-in-script","status":"publish","type":"post","link":"https:\/\/www.leonidassavvides.com\/blog\/2022\/04\/check-python-version-from-command-line-and-in-script\/","title":{"rendered":"Check the Python version from the command line and in the Python script"},"content":{"rendered":"<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div>\n<pre class=\"wp-block-syntaxhighlighter-code\">import os\n\n\ndef print_hi(name):\n    # Use a breakpoint in the code line below to debug your script.\n    print(f'Hi, {name}')  # Press \u2318F8 to toggle the breakpoint.\n\n\ndef ver_Py3():\n    #checking using cmd\n    #python --version\n    #using python script to get version\n    os.system(\"python --version\")\n    os.system(\"python -V\")\n    os.system(\"python -VV\")<\/pre>\n\n\n\n<p>\/Users\/leonidassavvides\/PycharmProjects\/pythonProject2\/venv\/bin\/python \/Users\/leonidassavvides\/PycharmProjects\/pythonProject2\/main.py<br \/>Hi, PyCharm<br \/>Python 3.10.4<br \/>Python 3.10.4<br \/>Python 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)]<\/p>\n\n\n\n<p>Process finished with exit code 0<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">The default interactive shell is now zsh.\nTo update your account to use zsh, please run chsh -s \/bin\/zsh.\nFor more details, please visit https:\/\/support.apple.com\/kb\/HT208050.\n(venv) leonidass-mbp:pythonProject2 leonidassavvides$ python --version\nPython 3.10.4\n(venv) leonidass-mbp:pythonProject2 leonidassavvides$ python -V\nPython 3.10.4\n(venv) leonidass-mbp:pythonProject2 leonidassavvides$ python -VV\nPython 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)]<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/Users\/leonidassavvides\/PycharmProjects\/pythonProject2\/venv\/bin\/python \/Users\/leonidassavvides\/PycharmProjects\/pythonProject2\/main.pyHi, PyCharmPython 3.10.4Python 3.10.4Python 3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)] Process finished with exit code 0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,21,22,24,34,43],"tags":[85,86,203,223,236],"class_list":["post-1438","post","type-post","status-publish","format-standard","hentry","category-dev","category-mac-os-x","category-macos","category-macs","category-python","category-tech","tag-check-python-version-from-script","tag-check-python-version-from-the-command-line","tag-python","tag-shell","tag-terminal"],"_links":{"self":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/posts\/1438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/comments?post=1438"}],"version-history":[{"count":0,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/posts\/1438\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/media?parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/categories?post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/tags?post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}