Python has gotten very confusing.
I started using Python just as Python 3 became a topic of discussion. Coming from Windows (which is famous for obsessively maintaining backwards compatibility long past the point of sensibility), I didn't understand how a new version of a piece of software could cause any controversy. Very quickly, I started to understand the issue and promptly quit using Python entirely.
The crux of the issue (as I grasped it) was dependencies and compatibility. Python thrives on packages: small-to-big collections of codes that you can slot into your own code to do something that you want. Think of browser extensions or apps you install on your phone: the browser/phone is doing most of the work, but the extension/app directs that work towards a specific goal. You could even think of this as a coach for a team: the team can theoretically do any number of things but it needs a coach to point it somewhere. The "team" is the browser and the "coach" is the extension.
Python has thousands – maybe tens of thousands – of packages, some new and some old. When the development team behind Python choose to create "Python 3", they willingly chose to break certain features of Python (i.e., fire some team members) and introduce new ones (i.e., hire new team members) for a variety of reasons I'm not privy to. The ones I remember were around the structure and "grammar" of the Python language, but I'm sure there were other reasons, perhaps security-based or perhaps based on incompatibility with newer OSes. Wikipedia has more, of course.
This led to much chest-beating and rabble-rousing, but the update happened and a bunch of stuff broke. Suddenly, it became very important which version of Python you had installed. Or, more likely, which versions.
This is where I see the concept of "virtual environments" becoming pertinent. The Python team, in PEP 405, states (emphasis mine):
The utility of Python virtual environments has already been well established by the popularity of existing third-party virtual-environment tools, primarily Ian Bicking’s virtualenv. Virtual environments are already widely used for dependency management and isolation, ease of installing and using Python packages without system-administrator access, and automated testing of Python software across multiple Python versions, among other uses.
Not being well-educated in programming (and working on Windows, which famously introduces a litany of issues for Python usage, starting with managing your PATH), I tried juggling separate installations of Python 2 and 3 for a while before giving up entirely. Mimicking a privately developed package appears to have been the Python team's solution to their problem.
A "virtual environment" is, basically, a copy of the folder that Python is installed to. PEP 405 again:
[venv is] a mechanism for lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (allowing creation of environments with various Python versions) and can have its own independent set of installed Python packages in its site directories, but shares the standard library with the base installed Python.
Or, from a description of the predecessor virtualenv on Stack Overflow:
It works by installing a bunch of files in a directory (eg:
env/), and then modifying thePATHenvironment variable to prefix it with a custombindirectory (eg:env/bin/). An exact copy of thepythonorpython3binary is placed in this directory, but Python is programmed to look for libraries relative to its path first, in the environment directory.
This is fundamentally what I was doing years ago in my naivety, but wrapped up in tools that handle a lot of the dirty work for you while requiring their own abstractions and magic words. And this is really what I wanted to get at.
I learned Python – originally – because it was sold as a straight-forward introduction to programming. A way for an intrigued beginner to dip their toes into a subject as profound and varied as carpentry or engineering. What I was told is no longer true, but the narrative persists.
Python is not for beginners. Maybe it never was, but for it to be used someone now has to grasp multiple layers of abstraction (my script relies on packages in a virtual environment in a root environment reliant on a language built on an operating system). Worse, sharing code – which must be an integral goal for any developer lest you spiral into maddening depths – is now a complete mess, where you need to educate your audience on all of those layers to explain the number of hoops they have to jump through.
Launching software is allowed to have 2 steps: click 1 and click 2. Getting the software can be more complex but not much more. It's no wonder that phones and web browsers are the places people spend their time: they're reliable environments (teams) for reliable tools/extensions/apps (coaches).