[Tutor] Command Lines

Alan Gauld alan.gauld at yahoo.co.uk
Thu Dec 24 05:36:44 EST 2020


On 24/12/2020 05:48, GardeGlory wrote:

> scraping script, however, I ran into a "pip install" problem, so, after
> hours of scrounging around trying to figure out what a "command line" is,
> can you guys give me a step-by-step to try and dumb it down for me? What is
> a command line? And how do I go from it to doing something like "pip


A command line is a prompt at which you type commands.
Exactly how you do that depends on your Operating System.
- On Linux for example I type Ctrl-Alt-T and a new Terminal
  window appears with a Bash command line.
- On Windoze I type Windows-R to get the run dialog then
  type CMD into that and hit OK to get a new CMD prompt window.
- On a Mac I have a shortcut to the Terminal application on the dock.
- On Android I have a shell app installed that I run in the usual
  manner to get a bash prompt there.

Once you have that prompt you can type commands such as
(Linux): ls, cd,  clear, mv etc...
(Windows): DIR, CD, CLS, RENAME, etc...
(Mac): same as Linux!
(Android): same as Linux:

What the prompt looks like depends on your user settings.
You can configire it as you like. The default prompt in
Windows is usually something like:

C:\WINDOWS>

ie a folder path followed by a >

In Unix based systems it is normally set up to be your
user name followed by the current folder path and possibly
the current command number (starting at 1 for each new session)
And finally a $ sign. If you are loggedin as the superuser
the $ will become a #. Thats important when following web
tutorials since if they show the # it means you need to be
logged in as superuser to execute the commands.

Something like

myuser at myhost ~/ $

In tutorials thats often abbreviated to just the last characer:

>

or

$

or

#

To run pip you can invoke it directly from the OS  command
prompt

> pip ....

However current thinking favours rinning pip from inside Python
so you would type:

> python -m pip ...

So that means at the OS prompt type python -m pip

followed by whatever pip options you need.

Finally, individual programs can have a command line, or prompt,
inside them too. Python is one such.

When you run python with no extra arguments you get the Python
interpreter which usually has a >>> prompt. There you can enter
Python commands and see the result immediately. This is a very
useful tool for exploring how Python commands work.

$ python
<some blurbb here...>
>>> print("Hello")
Hello
>>> help(print)
<explanation of print command here....>

When following tutorials make sure you are clear which command
line is being used - the OS or Python. Check the prompt symbol.

Hopefully that's enough to get you started. If you are still
having issues get back to us but tell us which OS you are using
and exactly how far you got.

Cut 'n paste any commands and error messages into the mail,
do NOT include screenshots as the server will throw them away.

Finally, check out the "Getting Started" topic in my
tutorial(see below) for more info on getting started
with the command line.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list