Installation hell

Peter J. Holzer hjp-python at hjp.at
Mon Dec 19 13:14:47 EST 2022


On 2022-12-20 04:15:07 +1100, Chris Angelico wrote:
> On Tue, 20 Dec 2022 at 03:56, Peter J. Holzer <hjp-python at hjp.at> wrote:
> > It is however, quite noticable that almost everyone who asks a question
> > about their Python installation on this list is using Windows. I don't
> > think this is just because there are more Windows users than Linux or
> > Mac Users.
> 
> Yes. I think there are a few reasons for that. One is that there are
> many many lazy people in the world, and those people are likely to (a)
> use the OS that came with their computers - usually Windows or Mac OS;

Yeah. But also on Linux you never have to set up Python. It's just
there, ready for use (a few years ago, when Python2 way still the
default, you might have had to "apt install python3"[1] but that's it).
So the lazy Linux users never run into these problems.

> > > I have a Linux VM that has several versions of Python3 on it.  Python3.8
> > > came installed with the distro, but for some programs I need Python 3.9+.
> > > If I forget which versions I have, how can I find out?
> >
> > I type python and then ctrl-D. The shell will then show me all commands
> > starting with "python" in my path (your shell may have a different key
> > combination for that, maybe tab-tab).
> 
> Ah, interesting. When I mentioned tab-tab I was aware that there are
> others, but I'm not familiar with Ctrl-D. Normally that means "send
> the command as it is",

It means that only in cooked mode. Since an interactive shell has to
switch the terminal into cbreak or even raw mode anyway, it can mean
whatever the the shell wants it to mean.

> so I assume your shell is set up to take an unfinished command and
> tab-complete it. Which shell is that?

zsh (with vi keybindings, although I think ctrl-D works the same with
emacs keybindings).

> (Also - what happens if you Ctrl-D in the middle of a line? Does that work?)

Yes. For example if I type "ls foo", dann move the cursor back after
"ls" and type " --co^D", I get:

% ls --co foo
--color    -- control use of color
--context  -- print any security context of each file

If I then type tab, it cycles through the options. If I select --color=
and type ^D again, I get

% ls --color= foo
always  auto    never

Etc.

Debian/Ubuntu contains a ton of predefined expansions for zsh. Many of
them are very context specific and invoke other commands to figure out
the actual options (I guess that it actually invokes ls --help to find
the options of help, and for psql it definitely checks which users or
databases a local postgres installation has to provide you with sensible
options at the appropriate position in the command line. There's also
remote filename expansion for scp and rsync, etc.)


> > But that works only for Python. Shell expansion works for any command.
> > If you use Linux, learn how to use your shell (and maybe learn different
> > shells - I personally prefer zsh, but I can also use bash, ksh, tcsh and
> > if necessary even sh).
> 
> I agree, although I wouldn't recommend trying to get too much out of
> sh as an interactive shell.

Yeah. If I happen to login to an account which has /bin/sh as the login
shell I'll invoke a different shell if I have to type more than 3 or 4
commands (and there is an alernative installed on the machine, which
these days is usually the case). But when I started to use Unix, the
Bourne shell was all there was. If you were lucky, there might have been
a csh, too, but that didn't use cursor keys either. At least it had a
history and you could use ! escapes to access it (I still use those in
zsh and bash).

        hp

[1] Or use yum or zypper or whatever, or your GUI package manager if
    that's your thing.

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20221219/6694b976/attachment.sig>


More information about the Python-list mailing list