(Chicken and the egg problem)
(Chicken and the egg problem)
Clearly Python eclipsed Perl. Just say'n.
Then several things happened. 1) Large businesses like Google openly saying they used Python in the early 2000s helped for things like web / Internet work. 2) Linux distros like Gentoo leaned on it heavily helped push it in systems/sysadmin. 3) the "Numeric -> NumPy/SciPy" transition helped a ton - spurred by things like `f2py` and exorbitant licensing costs of Matlab, the main competitor, which also had a lot of 1970s/early 80s language problems like 1-function per file and scoping craziness and not doing reference semantics for big matrices and junk like that. Then 4) the culture of open source in scientific software helped build out that aspect of the ecosystem as the other, 1/2/3 were growing fast. Then 5 by the late noughties/early teens universities were switching to it as a teaching language and finally 6 ML/data science as a specific area of the NumPy/SciPy world started taking off in hype cycles and even real applied work.
This is just a long-winded (but still woefully incomplete) / historical way of saying "software has network effects" (not just PLs, but OSes and applications as well), of course. As Jack Reacher likes to say "details matter in an investigation". ;-) I don't think Python was purely lucky, exactly, but with one or two those big reinforcement/feedback factors missing, it might not have become so dominant.