You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider initial bootstrapping concerns for pipenv-based tutorial #394
However, the current tutorial starts by introducing virtual environments, precisely because getting pip running reliably outside a virtual environment cross-platform with novice developers is a genuine pain due to the number of things that can go wrong - getting a single venv command to work, and then working inside the reconfigured shell avoids a lot of problems.
This means one of the core assumptions behind the structure of the new tutorial is wrong, and it's wrong in a way that means the current structure probably won't work :(
@jonparrott the Windows installers include pip, but don't put pip (or even Python) on your PATH by default. The canonical incantation on Windows is py -m pip, but if you have more than one Python installed it gets more complex. I think we can discount that for beginners, though (as having multiple versions of Python installed qualifies you as "not a beginner").
Having said this, I'm actually not quite sure myself what @ncoghlan is concerned about. The new tutorial at https://packaging.python.org/new-tutorials/installing-and-using-packages/ starts by saying you need to be able to run python and pip from your command line. Certainly it's non-trivial to get to that state in some environments, but we have to start somewhere, and this seems a reasonable point. We need to remember that this is an "Installing and using packages" tutorial, not a "beginning to learn Python" one.
If someone is completely unfamiliar with the command line, they may well be better off using a GUI environment or IDE like Visual Studio or PyCharm, which handles everything for them (including environment management, package installation, and running their code). At that stage, they don't really count as part of our audience.
(BTW, I'm currently teaching Python to a colleague at work, whose only prior programming experience is Oracle PL/SQL. I'll ask him to review the new tutorial and report back on his views - but my instinct is that he won't actually find it very useful at all).
starts by saying you need to be able to run python and pip from your command line.
I'm totally in favor of changing this to be python -m pip for Linux/Mac and py -m pip for windows. Oversight on my part for not doing that in the first place.
We need to remember that this is an "Installing and using packages" tutorial, not a "beginning to learn Python" one.
+1, but I think it's also useful for us to cross-link to other resources that are useful for Python beginners.
but my instinct is that he won't actually find it very useful at all)
Is that because of his personal experience or because of the tutorial? If the latter, why?
The problem I see is with getting pipenv itself to a reliably runnable state - we currently make the assumption that pipenv will just work, but the whole point of pipenv is that you run it without a virtual environment active, which means we're back into dealing with system PATH issues.
The original pip tutorial switched over to getting users into a virtual environment ASAP precisely due to the platform specific problems that arise when you don't have one active.
As such, I'm thinking it may still be worthwhile to have a two-tiered system where the baseline pip-and-venv-only tutorial is "I'm learning Python and the command line at the same time, and am happy enough with having exactly one initial Python environment to work in", while the second pipenv one is "I'm already familiar with the command line, and want to be able to easily manage multiple Python environments, and ensure my Python environments can be readily reproduced by other people on other systems".
That seems like a super confusing situation. I'd prefer to stick to one particular tool for the majority of use cases if possible.
The PATH stuff to get pipenv to work from the user install site seem to work fine, at least in my testing. We could get more users to give feedback on that, but I don't think it's severe enough to start backtracking on suggesting pipenv for mosts use cases.
Is that because of his personal experience or because of the tutorial? If the latter, why?
At the moment this is just my opinion, and I'll get his actual comments and report back. But my thoughts are:
I don't think he'll understand the explanation of why we're recommending pipenv. He managed OK to get python and pip working without assistance, and even installed numpy (into the system site-packages, I believe, but that's fine...). It's not at all clear, in terms he'd understand, why he needs pipenv. I believe he sees what he's doing as writing Python programs not projects, and the focus of the tutorial on "projects" will lead him to think it doesn't apply to him. Dependency management isn't something he'd see as an issue, he just views what he's doing as "installing extra stuff he needs", not "managing application dependencies". Deployment to him is handing someone a script with some instructions and letting them work out how to set up an environment where it'll run (this is not sloppy practice, or lack of experience, it's the nature of how adhoc scripts are managed in our environment). Environment isolation isn't something he'll understand the need for (I haven't even introduced him to virtual environments yet, as he's had no need for them yet).
He uses VS Code as his editor and runs his programs from within it. I don't know how he'd set that up to use the environment created by pipenv, and I'm sure he wouldn't be able to work out how to.
The discussion of user installs would confuse him. He's working on his own PC, everything on there is "his". And the fact that Windows Python installs per-user by default means he's not even seeing a UAC prompt when he tries to modify the system site-packages (which is a good thing, as he's not yet at a stage to understand that).
Note that he's not a complete computer newcomer. He does application support for "enterprise" systems, and works with Oracle SQL and PL/SQL. But he has no experience with "traditional" coding (C, Java, C#, Python, ...) and his interest in Python is for writing adhoc scripts, automation and monitoring code, data science applications, and for general interest.
The problem I see is with getting pipenv itself to a reliably runnable state
Personally, I use pipsi to set up a standalone pipenv installation. That's ideal, but far from a "beginner" level setup.
Ideally, tools like pipenv, pew, tox, and virtualenv (Python environment managers) would be better made available as standalone applications (maybe bundling a copy of Python, maybe adapting to locate and work with a system Python install). But the state of producing standalone deployments of Python code is even poorer than the state of dependency management tools, so we're a bit stuck there for now :-(
Right, I use pipsi as well, hence the instructions in https://pagure.io/modularity/fedmod to start out with sudo dnf install pipsi, then using that to bootstrap pew and pipenv.
If you're using an individual (i.e. not system wide) install of Python, then you can just do python -m pip install pipsi.
By contrast, if you're using a Linux or Mac OS X system install, then you need to do python -m pip install --user pipsi instead (and that may not work anyway, since a lot of Debian & Ubuntu systems still don't have the user's local bin directory on PATH by default).
Hence, even though https://docs.pipenv.org/install.html#fancy-installation-of-pipenv covers pipsi-based bootstrapping, it resorts to the non-Windows option of piping curl to python to get a pipsi bootstrapping technique that wasn't reliant on PATH being set correctly.
So I think we're going to have to make a fundamental choice in the design of the packaging tutorials: do we have the main installation tutorial assume that users will already have the ability to install and run pipenv, and then provide a separate guide for bootstrapping pipenv itself?
The current tutorial is able to avoid that question, because it can assume python -m venv exists.
You could manage an incantation of Python using urllib to replace curl. But no matter how you do it, there's a bootstrapping problem.
Hmm, I wonder whether pipsi would be a candidate for providing as a "standalone installer" (installer exe on Windows, whatever the equivalent is on Mac OS and Linux)? So "Install pipsi" would be a generic instruction that leads a new user to something that looks like any other platform install (much like the python.org installers), and then other projects can say "install pipsi then do pipsi install foo".
Aye, I think real Windows & Mac OS X installers for pipsi could help a great deal in the long run. Then the "find a suitable base version of Python to use" logic can exist inside pipsi, just as it does inside pipenv.
In the near term though, I think changing to the pipenv installation instructions in the tutorial to be:
We can then have separate Discussions on "Finding Python on a System" that talks about the different ways Python gets installed (and how the naming conventions work out), and "Managing Python Development Environments" that provides the rationale for why pipenv is the default.
That way, the tutorial could leave out the discourses on why things are the way they are, and instead just have a "troubleshooting" section at the end that the earlier sections refer to as needed. The end result would then be:
a documented happy path for when everything works as it should
explicit pointers for how to resolve common pain points
separate documents for the benefit of folks that know enough to ask "Why this, rather than that?" (complete beginners won't ask that, since they won't know the other options exist until we tell them about them)
He basically got stuck with the current document because the pip command won't work for him. The python command does, though. What he'd done is a default install of Python, then when he got to a point where he needed to run python from the command line, he hunted round, found the directory it had been installed in, and added that to PATH (but didn't know that he'd also need to add Scripts to his PATH because he hadn't needed a command that's in there yet).
So I've told him to try py -3 -m pip. But while that gets him able to run pip, it does mean that when the tutorial asks him to run pipenv he'll be back to square one, with that command not working. That sort of repeated failure will put him off immediately (he'd hunt for another guide/youtube video).
He did spot the note under Installing pipenv about user-base, but didn't spot that it's different from the system Scripts directory and pointed out that it should have been placed earlier, before he was asked to run pip. I suspected that if he'd followed the instructions in that section, he would have added the system Scripts directory but not the user Scripts directory, and would then have been frustrated when pipenvstill didn't work. In fact, when I asked him to review this comment, he said he would have added Roaming (user-site) and so would have got pipenv working, but still not have had pip working!
I honestly think that the "Installing and using packages" document should skip altogether the process of setting up your environment so that you have access to Python from the command line. That should be in a separate document - arguably the Python Setup and Usage guide should cover this, rather than it being the responsibility of the PUG to explain it. But even if we don't want to rely on the official Python docs, we should have a separate "Setting up your system to run Python" guide, with independent sections for each OS.
The killer here is that if we offer help on getting pip running, or setting up PATH, and the help we offer doesn't work, our readers will lose trust in the document and go elsewhere. That's not speculation, that's exactly what my colleague did - he went and found a YouTube video ("how to install matplotlib") - which was actually for Python 2.7, so probably had different issues he'd have hit in due course, but was better for his immediate needs than this guide.
Anyhow. I've asked him to read (but not actually do) the rest of the document, and let me know what he thinks. I don't want him to actually try using pipenv yet, because I think it'll end up with him in a mess with virtualenvs set up that he's unaware of that I won't be able to tidy up for him. Once I've seen what he thinks pipenv will do, and fed that back, I'll decide if it's worth getting him to actually try using it.
OK, having read the documentation on pipenv, I asked my colleague what he got from it. His answer was that he got the impression that pipenv was a "better" version of pip that was somehow "safer", but he didn't really have any feel for why it was safer or even what "safer" meant.
When I explained that pipenv managed packages on a per-directory basis, his reaction was "I don't want that". He expects, and wants, to install a package once and have it available to all his programs. He also hadn't picked up on the detail that you need to use pipenv run or pipenv shell to access the environment, so he'd have been puzzled and frustrated when he ran python and couldn't see his packages. Again, his reaction was "no, I don't want that".
When I explained the concept of virtual environments, and how installing software in the system environment can cause version clashes, etc, he got the principle, but still felt "that's not something I want to worry about yet". And he was of the view that if that's what the guide was explaining, then it wasn't the guide for him, and he'd go looking elsewhere for how to install packages without all of the extra concerns. He did also say that there should be documentation, up front at the start of the guide, that explains the problem that the guide is aimed at solving, to allow users like him to make the decision as to whether it's the right approach for him.
Thanks @pfmoore. I think our lack of clear reader personas may be hurting us here, as there's at least two major ones, and pipenv is only the right answer for one of them.
the first is a case like Paul's colleague: their use case for Python is "ad hoc personal scripting", rather than creating shareable software. For that, they just need clear guidance on setting up exactly 1 environment on their machine where they can run a command like "pip install requests" and then have "import requests" work in their code. As long as the resulting software works for the person that wrote it, it doesn't matter whether or not it works for anyone else. Ideally "per-user package installs" would be the right answer for this scenario, but the problems with PATH and the cross-platform python vs python3 vs py -3 distinction make that a bit awkward. This is the use case the existing tutorial targets.
the second is the collaborative development use case: whether as part of an open source project, or as part of paid work, or for some other reason, we not only want to install dependencies for our own use, but also explicitly declare them in a way that someone else can easily copy. This is the use case the new pipenv tutorial targets. The critical distinctions between pip install and pipenv install is then that the latter implicitly records what you requested in Pipfile, and what was actually installed as a result in Pipfile.lock.
And I think it would be possible to offer the two tutorials in parallel with minimal confusion specifically by framing it that way on the front page of https://packaging.python.org/. For example:
to learn how to install packages for your own personal use, see the tutorial on installing individual packages. (existing tutorial)
to learn how to manage dependencies in a collaborative project, see the tutorial on managing application dependencies. (new tutorial)
to learn how to package and distribute your own projects, see the tutorial on packaging and distributing. (existing tutorial)
We'd then position the two tools as "pip is a package installation tool, pipenv is a dependency management tool".
I've split out a separate issue regarding the initial bootstrapping of a "Baseline Python package management environment": #396
We may want to set the bar a little higher for the pipenv case, and require that folks get to a point where they can run these as a prerequisite and have them work properly:
pipsi install pew
pipsi install pipenv
It adds yet another layer to the bootstrapping stack (i.e. introducing pipsi for PyPI script management), but I think once folks are making the step up to collaborative dependency management, it's a layer they should be reasonably ready to cope with.
Activity
theacodes commentedon Nov 8, 2017
@ncoghlan hmm, I didn't run into any of these problems during testing. Am I missing something?
python-pippackages (although we could be more clear about using these).I need to double check on MacOS as that might be trickier.
pfmoore commentedon Nov 8, 2017
@jonparrott the Windows installers include pip, but don't put pip (or even Python) on your PATH by default. The canonical incantation on Windows is
py -m pip, but if you have more than one Python installed it gets more complex. I think we can discount that for beginners, though (as having multiple versions of Python installed qualifies you as "not a beginner").Having said this, I'm actually not quite sure myself what @ncoghlan is concerned about. The new tutorial at https://packaging.python.org/new-tutorials/installing-and-using-packages/ starts by saying you need to be able to run
pythonandpipfrom your command line. Certainly it's non-trivial to get to that state in some environments, but we have to start somewhere, and this seems a reasonable point. We need to remember that this is an "Installing and using packages" tutorial, not a "beginning to learn Python" one.If someone is completely unfamiliar with the command line, they may well be better off using a GUI environment or IDE like Visual Studio or PyCharm, which handles everything for them (including environment management, package installation, and running their code). At that stage, they don't really count as part of our audience.
(BTW, I'm currently teaching Python to a colleague at work, whose only prior programming experience is Oracle PL/SQL. I'll ask him to review the new tutorial and report back on his views - but my instinct is that he won't actually find it very useful at all).
theacodes commentedon Nov 8, 2017
I'm totally in favor of changing this to be
python -m pipfor Linux/Mac andpy -m pipfor windows. Oversight on my part for not doing that in the first place.+1, but I think it's also useful for us to cross-link to other resources that are useful for Python beginners.
Is that because of his personal experience or because of the tutorial? If the latter, why?
ncoghlan commentedon Nov 8, 2017
The problem I see is with getting
pipenvitself to a reliably runnable state - we currently make the assumption thatpipenvwill just work, but the whole point ofpipenvis that you run it without a virtual environment active, which means we're back into dealing with system PATH issues.The original
piptutorial switched over to getting users into a virtual environment ASAP precisely due to the platform specific problems that arise when you don't have one active.As such, I'm thinking it may still be worthwhile to have a two-tiered system where the baseline pip-and-venv-only tutorial is "I'm learning Python and the command line at the same time, and am happy enough with having exactly one initial Python environment to work in", while the second pipenv one is "I'm already familiar with the command line, and want to be able to easily manage multiple Python environments, and ensure my Python environments can be readily reproduced by other people on other systems".
theacodes commentedon Nov 8, 2017
That seems like a super confusing situation. I'd prefer to stick to one particular tool for the majority of use cases if possible.
The PATH stuff to get pipenv to work from the user install site seem to work fine, at least in my testing. We could get more users to give feedback on that, but I don't think it's severe enough to start backtracking on suggesting pipenv for mosts use cases.
pfmoore commentedon Nov 8, 2017
At the moment this is just my opinion, and I'll get his actual comments and report back. But my thoughts are:
Note that he's not a complete computer newcomer. He does application support for "enterprise" systems, and works with Oracle SQL and PL/SQL. But he has no experience with "traditional" coding (C, Java, C#, Python, ...) and his interest in Python is for writing adhoc scripts, automation and monitoring code, data science applications, and for general interest.
pfmoore commentedon Nov 8, 2017
Personally, I use
pipsito set up a standalonepipenvinstallation. That's ideal, but far from a "beginner" level setup.Ideally, tools like
pipenv,pew,tox, andvirtualenv(Python environment managers) would be better made available as standalone applications (maybe bundling a copy of Python, maybe adapting to locate and work with a system Python install). But the state of producing standalone deployments of Python code is even poorer than the state of dependency management tools, so we're a bit stuck there for now :-(ncoghlan commentedon Nov 8, 2017
Right, I use
pipsias well, hence the instructions in https://pagure.io/modularity/fedmod to start out withsudo dnf install pipsi, then using that to bootstrappewandpipenv.If you're using an individual (i.e. not system wide) install of Python, then you can just do
python -m pip install pipsi.By contrast, if you're using a Linux or Mac OS X system install, then you need to do
python -m pip install --user pipsiinstead (and that may not work anyway, since a lot of Debian & Ubuntu systems still don't have the user's local bin directory on PATH by default).Hence, even though https://docs.pipenv.org/install.html#fancy-installation-of-pipenv covers pipsi-based bootstrapping, it resorts to the non-Windows option of piping
curltopythonto get a pipsi bootstrapping technique that wasn't reliant onPATHbeing set correctly.So I think we're going to have to make a fundamental choice in the design of the packaging tutorials: do we have the main installation tutorial assume that users will already have the ability to install and run
pipenv, and then provide a separate guide for bootstrappingpipenvitself?The current tutorial is able to avoid that question, because it can assume
python -m venvexists.pfmoore commentedon Nov 8, 2017
You could manage an incantation of Python using urllib to replace curl. But no matter how you do it, there's a bootstrapping problem.
Hmm, I wonder whether pipsi would be a candidate for providing as a "standalone installer" (installer exe on Windows, whatever the equivalent is on Mac OS and Linux)? So "Install pipsi" would be a generic instruction that leads a new user to something that looks like any other platform install (much like the python.org installers), and then other projects can say "install pipsi then do
pipsi install foo".ncoghlan commentedon Nov 8, 2017
Aye, I think real Windows & Mac OS X installers for
pipsicould help a great deal in the long run. Then the "find a suitable base version of Python to use" logic can exist insidepipsi, just as it does insidepipenv.In the near term though, I think changing to the pipenv installation instructions in the tutorial to be:
py -3 -m pip install --user pipenv(Windows)python3 -m pip install --user pipenv(everywhere else)would be enough to deal with my main concerns.
We can then have separate Discussions on "Finding Python on a System" that talks about the different ways Python gets installed (and how the naming conventions work out), and "Managing Python Development Environments" that provides the rationale for why
pipenvis the default.That way, the tutorial could leave out the discourses on why things are the way they are, and instead just have a "troubleshooting" section at the end that the earlier sections refer to as needed. The end result would then be:
pfmoore commentedon Nov 9, 2017
First batch of feedback from my colleague.
He basically got stuck with the current document because the
pipcommand won't work for him. Thepythoncommand does, though. What he'd done is a default install of Python, then when he got to a point where he needed to runpythonfrom the command line, he hunted round, found the directory it had been installed in, and added that toPATH(but didn't know that he'd also need to addScriptsto hisPATHbecause he hadn't needed a command that's in there yet).So I've told him to try
py -3 -m pip. But while that gets him able to run pip, it does mean that when the tutorial asks him to runpipenvhe'll be back to square one, with that command not working. That sort of repeated failure will put him off immediately (he'd hunt for another guide/youtube video).He did spot the note under Installing pipenv about user-base, but didn't spot that it's different from the system
Scriptsdirectory and pointed out that it should have been placed earlier, before he was asked to run pip. I suspected that if he'd followed the instructions in that section, he would have added the systemScriptsdirectory but not the userScriptsdirectory, and would then have been frustrated whenpipenvstill didn't work. In fact, when I asked him to review this comment, he said he would have addedRoaming(user-site) and so would have gotpipenvworking, but still not have hadpipworking!I honestly think that the "Installing and using packages" document should skip altogether the process of setting up your environment so that you have access to Python from the command line. That should be in a separate document - arguably the Python Setup and Usage guide should cover this, rather than it being the responsibility of the PUG to explain it. But even if we don't want to rely on the official Python docs, we should have a separate "Setting up your system to run Python" guide, with independent sections for each OS.
The killer here is that if we offer help on getting pip running, or setting up PATH, and the help we offer doesn't work, our readers will lose trust in the document and go elsewhere. That's not speculation, that's exactly what my colleague did - he went and found a YouTube video ("how to install matplotlib") - which was actually for Python 2.7, so probably had different issues he'd have hit in due course, but was better for his immediate needs than this guide.
Anyhow. I've asked him to read (but not actually do) the rest of the document, and let me know what he thinks. I don't want him to actually try using pipenv yet, because I think it'll end up with him in a mess with virtualenvs set up that he's unaware of that I won't be able to tidy up for him. Once I've seen what he thinks pipenv will do, and fed that back, I'll decide if it's worth getting him to actually try using it.
pfmoore commentedon Nov 9, 2017
OK, having read the documentation on pipenv, I asked my colleague what he got from it. His answer was that he got the impression that pipenv was a "better" version of pip that was somehow "safer", but he didn't really have any feel for why it was safer or even what "safer" meant.
When I explained that pipenv managed packages on a per-directory basis, his reaction was "I don't want that". He expects, and wants, to install a package once and have it available to all his programs. He also hadn't picked up on the detail that you need to use
pipenv runorpipenv shellto access the environment, so he'd have been puzzled and frustrated when he ranpythonand couldn't see his packages. Again, his reaction was "no, I don't want that".When I explained the concept of virtual environments, and how installing software in the system environment can cause version clashes, etc, he got the principle, but still felt "that's not something I want to worry about yet". And he was of the view that if that's what the guide was explaining, then it wasn't the guide for him, and he'd go looking elsewhere for how to install packages without all of the extra concerns. He did also say that there should be documentation, up front at the start of the guide, that explains the problem that the guide is aimed at solving, to allow users like him to make the decision as to whether it's the right approach for him.
ncoghlan commentedon Nov 10, 2017
Thanks @pfmoore. I think our lack of clear reader personas may be hurting us here, as there's at least two major ones, and
pipenvis only the right answer for one of them.the first is a case like Paul's colleague: their use case for Python is "ad hoc personal scripting", rather than creating shareable software. For that, they just need clear guidance on setting up exactly 1 environment on their machine where they can run a command like "pip install requests" and then have "import requests" work in their code. As long as the resulting software works for the person that wrote it, it doesn't matter whether or not it works for anyone else. Ideally "per-user package installs" would be the right answer for this scenario, but the problems with
PATHand the cross-platformpythonvspython3vspy -3distinction make that a bit awkward. This is the use case the existing tutorial targets.the second is the collaborative development use case: whether as part of an open source project, or as part of paid work, or for some other reason, we not only want to install dependencies for our own use, but also explicitly declare them in a way that someone else can easily copy. This is the use case the new
pipenvtutorial targets. The critical distinctions betweenpip installandpipenv installis then that the latter implicitly records what you requested inPipfile, and what was actually installed as a result inPipfile.lock.And I think it would be possible to offer the two tutorials in parallel with minimal confusion specifically by framing it that way on the front page of https://packaging.python.org/. For example:
We'd then position the two tools as "
pipis a package installation tool,pipenvis a dependency management tool".pfmoore commentedon Nov 10, 2017
That sounds good. I just checked with Ian (my colleague) and he agreed - that would have suited him perfectly.
theacodes commentedon Nov 10, 2017
Alright, sounds like we have a way forward here, I'm going to try to make more progress on this soon.
ncoghlan commentedon Nov 11, 2017
I've split out a separate issue regarding the initial bootstrapping of a "Baseline Python package management environment": #396
We may want to set the bar a little higher for the
pipenvcase, and require that folks get to a point where they can run these as a prerequisite and have them work properly:It adds yet another layer to the bootstrapping stack (i.e. introducing
pipsifor PyPI script management), but I think once folks are making the step up to collaborative dependency management, it's a layer they should be reasonably ready to cope with.ncoghlan commentedon Nov 29, 2017
PR: #402
theacodes commentedon Feb 9, 2018
@ncoghlan can we consider this closed or is there still actionable steps here?
ncoghlan commentedon Feb 10, 2018
Aye, I think this is done now that we decided to make dependency management a separate tutorial from basic package installation.