An opinionated guide to Python environments in 2021
Note: If you don’t want to read the blah-blah context and history stuff then you can jump to the recommendations
The Problem
The need for virtual python environments becomes fairly obvious early in most Python developers’ careers when they switch between two projects and realise that they have incompatible dependences (e.g. project1 needs scikit-learn-0.21
and project2 needs scikit-learn-0.24
). Unlike other mainstream languages like Javascript(Node.js) and Java (with Maven) where dependencies are stored locally to the project, Python dependencies are installed at system or environment level and affect all projects that are using the same environment.
When you run into this problem — you have two choices: you can either play around with the libraries you have installed and risk breaking things for one of your projects and not being able to get it back or you search “python incompatible dependencies install both?” with a hopeful glimmer in your eye as you hit enter.
Virtual Environments and Package Managers
Virtual environments are the community approved way to manage this issue and likely the first hit you’ll get with the above search in your…