This code first imports the sys module then prints out the contents of the version variable: Below you can see an example of how the sys module’s version variable renders the current Python version. The sys module has a variable you can reference to get the current Python version. The choice of which option to use really comes down to what format you want the output in. Using either a script or the Python shell, you can use one of the code snippets below to print your Python version.īoth options work equally well regardless of your system. You can also check your installed Python version from within Python itself. How to Check the Python Version from Python The command for checking the installed version of Python 3 remains otherwise the same - just use python3 with the -version option: python3 -version In these cases, you only have the python3 command. In fact, some systems use the python3 command even when they do not have Python 2 installed alongside Python 3. In these cases, to check your version of Python 3, you need to use the command python3 instead of python. Some systems distinguish between Python 2 and Python 3 installations. Enter the following command from your command line, and you should get an output similar to the one shown below: python -version It works just as straightforwardly as it sounds. The Python command comes with a command line option of -version that allows you to see your installed version. How to Check the Python Version from the Command Line Here, you can find the command line method as well as a Python script method for retrieving the current Python version. This tutorial shows you how to check your Python version, for both Python 2 and Python 3. This can help you make decisions about compatibility, upgrades, and more. Thus, you may want to know where you can find information on your installed Python version. Many tools and Python development libraries require a particular version of Python. In fact, your system likely already has at least one version of Python installed. That may help point to previously improperly removed installations.Python reigns as one of the most popular programming languages, with a wide range of programs and developer tools relying on it. You could have some insight to this by opening "regedit" and searching for "Python27" - a registry key appeared in my command-shell Cache pointing at c:\python\python27\ (which had been removed and was not present when searching in the registry upon finding it). This is not the answer that addresses registry key issues (others mention that) but it is somewhat of a workaround if you know of previous installations that were improperly removed. It was happy locating those items and removing them, and proceeded with the install. I placed a copy of Python27 back in that original folder, at C:\Python\Python27, and re-ran the same failing Python27 installer. It would always back out while trying to 'remove shortcuts' during the installation process. Upon re-installing Python27, it gave the above error you specify. Py27 was removed manually from C:\python\Python27 (the folder Python27 was deleted by me previously) I'm using Py.exe to route to Py2 or P圓 depending on the script's needs - but I previously improperly uninstalled Python27 before. Windows 7 64-bit, with both Python3.4 and Python2.7 installed at some point :)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |