Intro
Was working on a project across two different machines, it was a flask server, where one was Linux and the other Windows. I found that they use different Python versions and so the dependencies also were different versions.
While resolving the PIP packages between them (Windows was being annoying) and Pycharm kept warning me, I figured there must be a better way of doing this.
There is.
Starting A New Python Project
The Python ecosystem has something called virtual environments, vnev, and it’s literally just that.
We can create a virtual env for a project to run across machines, operating systems, etc.
When starting a new project do the following in your terminal:
python -m venv venvThe venv that is created is isolated from the global Python version and the packages you have installed, this resolves issues with different versions
Taking A Snapshot of Packages
To make a list of your dependencies and the like, pip has a handy command for us.
pip freeze > requirements.txtThis is the PIP equivalent of package.json from the nodejs ecosystem, but stored in a text file, named requirements.txt by convention but can also be a toml file instead.
// Personally, I'm surprised there's not a more robust built in solution already.
Recommended Packages for better DX
List from Coding with Lewis
Use docker instead of VENV for Python???
uvpackage manager (and more)Ruff(linter and formatter)- Arcade.dev (MCP Servers)
- Type Checkers (couple options)
PyTestPydantic