On Fri, 26 Feb 2021 at 09:07, Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Fri, Feb 26, 2021 at 11:41:56AM +0900, Stephen J. Turnbull wrote:
> > Mike Miller writes:
> >
> >  > "sys-admin" is a bit of an overstatement in my phrasing.  The core
> >  > is that you need to understand how a PATH works and be able to run
> >  > pip and cd into folders and perhaps run rm/del, etc.  Basic
> >  > command-line skills?
> >
> > That's what I would mean by basic sys-admin skills.  And *surprise!*
> > my students don't have them, and don't need them ... until they start
> > using Python.
>
> Is it *only* Python though? Wouldn't that be necessary if they were
> learning Perl, Java, C, Ruby etc?

It is possible to teach students to do most things in Python without
using the command line. For example you can tell them all to install
anaconda and then use spyder as their editor. Or you can get them to
install and use vscode or pycharm or some other IDE with built in
virtualenv and git integration etc.

Where Python is awkward is at the point where you actually *want* to
teach students to use the command line. The problem is that Python is
not set up for command line use out of the box in a consistent way
across different platforms.

It would be nice to say: now open a terminal, type "python", and hit
the enter key and you'll see the Python prompt >>> but it's just not
that simple so the instructions end up being like:
"""
It might be possible to run python from the terminal by typing
"python". However that might not work or it might run the wrong
version/installation of Python. It might be that you haven't added
Python to your PATH environment variable or maybe you have depending
on which boxes you ticked when installing. Possibly you need to change
your PATH environment variable or possibly you should run Python as
"python3" or "py" instead but I have no way of saying without knowing
what OS you are on, where you installed Python from, what options you
selected in the installer, whether you have any other Python
installations etc. If you are on Windows and you get "permission
denied" then that's possibly because the MS-provided python.exe stub
is on your PATH so you first need to disable that in "app execution
aliases". Possibly you can't run Python from the normal terminal but
you can open a special terminal for Python that does have the PATH set
up such as the Anaconda Prompt.

Okay next lesson is how to use "pip" which is really easy: just type
"pip install X" but maybe you should actually type "pip3" or "python
-m pip" or "python3 -m pip" or "py -m pip" or actually you if you
installed Anaconda you might need to use "conda install X".
"""
When someone learns to use the command line for the first time it's
really quite helpful if you can tell them exactly what commands to
type. Knowing how to configure PATH and understanding what it does and
understanding about OS differences etc is potentially useful in the
long run but is a major distraction at the beginning.

There have been efforts to improve the situation but in some ways they
make it worse. For example the py launcher supposedly fixes some of
these problems on Windows but the fact that there is no analogue of it
on any non-Windows platform means that any instructions involving it
immediately need to split according to OS. Likewise the new python.exe
stub that ships with Windows is supposed to fix the Python PATH
problem but it actually *prevents* python from working in the terminal
if you have installed Python some other way (even if you have added it
to PATH):
https://stackoverflow.com/questions/56974927/permission-denied-trying-to-run-python-on-windows-10

The problems aren't only on Windows because you also have "python" vs
"python3" on OSX, Linux etc. On OSX you can also have conflicts
between the system Python and any user installed Python. On OSX some
installers set up the PATH for you by automagically editing
.bash_profile which can be helpful but can also be confusing. After
some time people don't actually know how to run the different versions
of Python that they installed through homebrew, from python.org or
from Anaconda etc and their .bash_profile is a mess. The question of
exactly what you should type to run python, pip, etc applies on Linux
although I find it less problematic just because Linux users typically
know how to use the terminal already.

For me as a user of Python I don't usually notice these problems
because I use some sort of virtual environment for everything so I can
always type "python" or "pip" and there are no conflicts between
different installations. When a student can't even get "python" to
work in the terminal though it's too much to ask them to start setting
up virtual environments.

--
Oscar
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZNMWRFR7PR7AISBUPBSE32WSNYZFUXCF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to