Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python command interface
#1
Brand new to python....I just downloaded from python site and I am watching a training video. The video is telling me to run python --version and all I am getting is errors. Not sure what I am doing wrong.

Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> python --version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
>>>
Reply
#2
so after installing Python you need an editor. https://www.jetbrains.com/pycharm/downlo...s&code=PCC
Reply
#3
This python3 --version should be executed from a shell. As for editor, it makes writing code easier. There are many editors to choose. My preference is vscode. Others are pycharm, notepad++, atom (atom no longer has support), and others.
Hope this helps.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#4
Python comes with an IDE called Idle, said to be very suitable for beginners. I only use Idle.

Most Linux versions have Python and with it Idle. You should find an icon to start Idle in the Accessories. Or search for Idle.

Have a look [url=How to get Idle]here[/url]

If you use windows, there must be an equivalent, I suppose
Reply
#5
Basically, as everyone else has stated, you are running a commandline instruction inside of Python.

python --version
is a command to ask the computer what version of Python you have installed. So, when you have just opened your commandline editor (cmd in Windows) and type this, you should get a few lines that tell you the version you have.

However, it looks as if you have already run a command in the commandline window; the command being python (or python3, or sometimes py). This is because the lines you show are actually Python running:

Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
You can see the version of Python you have installed (Python 3.11.5), keywords you could type to help you ("help", "copyright", etc), and then the prompt for you to enter any Python command you might wish to run.

Now, this might be within the immediate window of Idle (if you ran Idle and then typed the command Python --version).

Either way, why not look for the waiting prompt and simply type a Python instruction:

>>>

Is the prompt. So, try the following:

>>> print("This is a Python command to send something to the default output device")

Now press the ENTER key and you should then see the text in the brackets appear below the line you just typed.
Reply
#6
from within a python script (if this is what you want), you can use:
import sys

vinfo = sys.implementation.version
print(f"python version: {vinfo.major}:{vinfo.minor}:{vinfo.micro} release: {vinfo.releaselevel}")
This will produce something like:
Output:
python version: 3:11:4 release: final
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  os.system("netsh interface set interface 'Wi-Fi' enabled") aniyanetworks 12 10,204 Jan-18-2019, 04:07 AM
Last Post: aniyanetworks
  Interface Arduino and MSSQL using Python MichaelDean 0 2,906 Nov-18-2018, 05:00 PM
Last Post: MichaelDean
  Python Interface for HWM14 sdipti596 4 5,320 Dec-26-2017, 10:21 PM
Last Post: Terafy
  Python interface only black and white........ Wilson 3 6,171 Jul-15-2017, 01:20 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020