Great suggestions and a horrible article. Every point is followed up with a bunch of sassy quips with no explanation as to why, or worse "subscribe to our blog and maybe we will complete this article at an unspecified later date"
For everyone else reading:
Don’t install the latest major version of Python
Real reason: many packages don't support the latest major python release right out of the gate - As of last time I checked, Numba doesn't work on 3.11, nor does many of the new Torch 2.0 features. Waiting a few months to upgrade will likely alleviate a lot of headaches as far as package compatibility, IDE support, etc. is concerned
Use only the python.org installer on Windows and Mac, or official repositories on Linux.
This is the most secure way to install python, and the installation from different sources do slightly different things with the system paths - If you trust 3rd party sources and are aware of the differences between them and the official installer this is a non-issue. Ironically the article advocates adding an unofficial PPA on linux to install different python versions - contradict yourself much
Never install or run anything outside of a virtual environment
If you write program 'A' outside of a virtual environment, and then start working on program 'B', installing dependency 'XYZ' may update package 'EFG' to a version program 'A' does not support. Virtual environments ensure all of your programs are isolated and making changes to one environment doesn't break something in a totally different project
Limit yourself to the basics: “pip” and “venv”
Part of the reason why the python packing ecosystem is so fractured and confusing is because every time someone has a slight issue with the built-in components they decide they need to build out a brand new packaging ecosystem - if everyone knew how to use pip and venv properly, then they likely wouldn't have any issues with them. However, everyone reads some 8 year old blog article telling everyone they NEED to use conda/virtualenvwrapper/etc to address some shortcoming with pip that no longer exists, which means these people never learn how to use pip/venv properly, and the cycle proliferates. You are free to convince me of the need to use "tool xyz" because of say, better dependency resolution, but at the end of the day the time lost learning said new tool is going to be much greater than the grand total of 3 minutes I have lost to manually resolving dependencies in the 10 years I've been developing with python
If you run a command, use “-m”
Theory: this ensures you are running the command that is associated with the specific version of python you are using. venv/bin/python -m pip will run the pip version installed to that specific virtualenv
Practice: This is no different than directly calling the binary, e.g. venv/bin/pip or doing a source venv/bin/activate when you enter your project directory, which lets you call the pip directly to access the relevant binary.
3
u/bjorneylol Mar 28 '23
Great suggestions and a horrible article. Every point is followed up with a bunch of sassy quips with no explanation as to why, or worse "subscribe to our blog and maybe we will complete this article at an unspecified later date"
For everyone else reading:
Real reason: many packages don't support the latest major python release right out of the gate - As of last time I checked, Numba doesn't work on 3.11, nor does many of the new Torch 2.0 features. Waiting a few months to upgrade will likely alleviate a lot of headaches as far as package compatibility, IDE support, etc. is concerned
This is the most secure way to install python, and the installation from different sources do slightly different things with the system paths - If you trust 3rd party sources and are aware of the differences between them and the official installer this is a non-issue. Ironically the article advocates adding an unofficial PPA on linux to install different python versions - contradict yourself much
If you write program 'A' outside of a virtual environment, and then start working on program 'B', installing dependency 'XYZ' may update package 'EFG' to a version program 'A' does not support. Virtual environments ensure all of your programs are isolated and making changes to one environment doesn't break something in a totally different project
Part of the reason why the python packing ecosystem is so fractured and confusing is because every time someone has a slight issue with the built-in components they decide they need to build out a brand new packaging ecosystem - if everyone knew how to use pip and venv properly, then they likely wouldn't have any issues with them. However, everyone reads some 8 year old blog article telling everyone they NEED to use conda/virtualenvwrapper/etc to address some shortcoming with pip that no longer exists, which means these people never learn how to use pip/venv properly, and the cycle proliferates. You are free to convince me of the need to use "tool xyz" because of say, better dependency resolution, but at the end of the day the time lost learning said new tool is going to be much greater than the grand total of 3 minutes I have lost to manually resolving dependencies in the 10 years I've been developing with python
Theory: this ensures you are running the command that is associated with the specific version of python you are using.
venv/bin/python -m pipwill run the pip version installed to that specific virtualenvPractice: This is no different than directly calling the binary, e.g.
venv/bin/pipor doing asource venv/bin/activatewhen you enter your project directory, which lets you call thepipdirectly to access the relevant binary.