[Python-ideas] Looking for input to help with the pip situation

Chris Barker chris.barker at noaa.gov
Mon Nov 13 13:30:43 EST 2017


On Sun, Nov 12, 2017 at 3:18 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> P.S. As a user, it's also genuinely irritating to have to always type
> the "python -m " prefix when inside an active virtual environment, as
> in that case, there isn't any ambiguity about which environment pip
> should be manipulating or which version of Python it should be using.
>

and not just there :-)

I decided a year or two ago to recommend "python -m pip install" to my
beginning students, and put it all my course documentation. I've done this
for a while now.

but last week, when I introduced pytest -- I said, if you haven't'
installed pytest yet, do it now -- and then proceeded to type:

pip install pytest

In my terminal, projecting in a huge font  for all the class to see.

It's just too ingrained and easy.

And the truth is, it actually works MOST of the time.

And if it doesn't work right, you are either a semi-sophisticated user that
needs multiple pythons accessible from your shell, or your system is
mis-configured.

Pain though it is, it's probably better to help newbies configure their
systems correctly than to try to get everyone to invoke pip differently.

In fact, I have a little excercise that my students do as teh very first
thing in class:

https://uwpce-pythoncert.github.io/PythonCertDevel/supplemental/HowToRunAPythonFile.html#making-sure-you-are-set-up-correctly

If you don't want to go read that:

I give them this code:

(not as a downloadable python file)

#!/usr/bin/env python
import sysprint("This is my first python program")
version = sys.version_info
if version.major == 3:
    if version.minor != 6:
        print("You should be running version 3.6")
    else:
        print("You are running python3.6 -- all good!")else:
    print("You need to run Python 3!")
    print("This is version: {}.{}".format(version.major, version.minor))


And I have them put it in a file, save it and run it however they want to
run it.

I then know that they:

Know how to create a new python file, put some code in it and run that code.

and

They are running the version of Python I want them to run.

(though to be fair, I had one student struggling for weeks with "strange"
errors, because his PyCharm was setup to run python2. He probably started
using PyCharm after he ran that script some other way...)

I suppose I should do something similar to check that they have pip
properly configured also, but to some extent, that comes up the first time
I have them pip install something -- which is in the first class anyway :-)

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171113/ae29f160/attachment.html>


More information about the Python-ideas mailing list