This post is mostly used to document my current Python setup before I get my next Mac where I am going to venture into new setup using pipenv. So far I have had a setup strategy using virtualenvs and virtualenvs only but I have had tests with pipenv and it seems to solve some of the issues I’ve had with my setup.
For background, Python has deservedly a bad reputation about dependencies management. Sooner or later you will get things tangled up and in tears. R people mock us for many reasons but there is no excuses here: Python external modules management is a mess and none of the solutions are very good. This means every Pythonista finds their own set up that kind of does what is needed but still is lacking. Following is my set up that I’ve ended up with, not because it is perfect but because it is where I am at now.
My setup is built on following principles or guidelines:
pythonyou will get trusty old Python 2.7 only invited to system management tasks and nothing else
These principles make it easier to go back to a working set up when something goes awry. And something will.
Following these principles it means that in the beginning you will have just system Python, pip Installation — pip 20.2.4 documentation and virtualenv Installation — virtualenv 20.1.1.dev5+g9708b54 documentation
When starting a project I will following steps:
pip freeze > requirements.txt)
Additionally, when project is larger I create two virtualenvs: projectname and projectname-dev. The latter will have more stuff for development and testing (for instance coverage and pytest). For quick, local projects all dependencies are in one project.
Additionally, for prototyping I have created a virtualenv called “basics” and a system wide alias that activates it and moves to a directory called “notebooks” and then runs “jupyter notebook” in that directory. This virtualenv has needed tools to quickly try out things in a jupyter notebook from requests to sklearn and numpy.