To check the version of one's Python's Software version, one should use the following code in command prompt:
python -V
Reference: http://docs.python.org/using/cmdline.html#generic-options
Answer from theglauber on Stack OverflowVideos
To check the version of one's Python's Software version, one should use the following code in command prompt:
python -V
Reference: http://docs.python.org/using/cmdline.html#generic-options
In a Python IDE, just copy and paste in the following code and run it (the version will come up in the output area):
import sys
print(sys.version)
If you have installed Python Launcher for Windows, you have several alternatives.
You can pass the desired Python version at the command line, like this:
> py -3.11 path\to\python\script.py
If you don't want to pass the version at the command line, you can use a valid shebang as the first line in your python script. For example, this is valid on Windows, assuming the path to your Python 3.11 executable is C:\Python311\python.exe:
#! c:\Python311\python.exe
See this for a discussion of python shebang on Windows: https://stackoverflow.com/questions/7574453/shebang-notation-python-scripts-on-windows-and-linux
But, I'm only able to get this to work if using Python Launcher for Windows, i.e., running py as my command, not python.
A more detailed answer can be found here: https://stackoverflow.com/questions/20786478/how-to-run-different-python-versions-in-cmd
You could use a virtual environment and set the python version you want to use in it using python<version> -m venv <envname>.
This way the packages you want to install for running that particular program can also be isolated from interfering with the global packages. More info on that can be found here: https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv
Evening r/Python
The reason for this post is because i am having trouble checking my Python version using the command prompt. Am originally a Mac user, so not sure if the PC transition is what has me confused. Anyways, i know i have Python Version 3.7 installed in my system. However, when i run the python --version command line in both the regular command prompt and administrator command prompt, i get THIS error message.
How come.? This is not really about what version I'm running, as it is about me trying to use the pip install command to install packages. But i figured start at the begging so if command prompt won't even recognize my python installation, why first waste my time trying to figure out why is wont recognize the pip call.
Anyhow, any comments/suggestions would be greatly appreciated. Thank you in advance and good day.! Cheers.! :)