New pc: how do I install python *correctly* this time?
I've got some years of python+data experience through work, but the environments were always already set up. I installed various pythons on my own laptop (RIP, asus strix), but it was something like the basic python from official site, via the conda installer, and various updates and packages over time. Needless to say, it was not a production-worthy environment, but it let me do my own hobby projects just fine.
I recently got a new laptop and am looking to install python "correctly" this time so I can work on more substantial projects. I mean like, clean install, proper PATH (though I don't know wtf this means), virtualenvs, all that jazz.
Can anybody recommend some guides or walkthroughs for this? Poking around I find a variety of "best python install" guides that don't all align on best practices. Yes, I use windows because I'm a pleb. In the future I might do another linux installation via some VM, but not yet.
Thanks!
Posted Oct 30, 2021, 12:05 AM UTC
Perfectly fine to use Windows, that's my personal preference (combined with WSL).
I usually recommend using the standard Python installation, but if you're focused on doing data science Anaconda is technically a better fit. I'm going to assume you want a more generalised setup, so I'm going to explain the first one. Correct me later if you so wish.
So, simply go to python.org and download the latest version, or at least 3.9 if you're not sure what you need supports 3.10 yet. When you run the installer, to make stuff easier in the beginning check the box to add Python to PATH, then just let the installer do its thing. Finally, once installed, check the box to disable the path length limit just in case - you probably won't need it, but it doesn't hurt.
And that should be everything done for the basics. Virtual environments aren't a hard requirement on Windows if you ask me, but it's probably a good idea to get used to them. Personally I recommend using Poetry so that you don't have to worry about it at all yourself and because it's very modern, but you can get by without anything or by using the built-in
venvif you so wish.Since Python was added to PATH, you should have direct access to running
python,pip, and any tools you might install via PyPI directly. If you didn't, you'd use them via the includedpy-launcher.That is all. Use whatever editor you fancy, I like VS Code with Python but you should try out different ones and find one you like yourself.
Can you expand on this? How do you manage having multiple projects when conflicting dependencies and how do you ensure everyone working on the codebase can reproduce the build?
The main reason virtual environments are practically a requirement on Linux distros and Mac OS is because they depend on Python. So if you're using the system-provided Python, you don't want to mess with any of their libraries. That's where the virtual environments come in.
You're of course correct in that you can't by default manage projects with conflicting dependencies or create reproducible builds without additional tools. This is true no matter the operating system. However, in my opinion a beginner is less likely to run into the first scenario, and the second one comes more into play when working as a team. But if one was to need that, sure, virtual environments would be a solution.
I'll quote a comment I made the other day:
pdm, as described above, can be thought of as Poetry that uses PEP 582 instead of a virtual environment. I recommend reading up on both, as I find it a very interesting alternative.FYI the installation speed with pdm slow like a fuck.
Ah I see what you mean.
I though you were saying that venvs/isolation of dependencies was not necessary for developers or in general.
It makes sense to try not to overwhelm beginners.
I've seen plenty of posts here for that exact reason, mainly because PyCharm uses them by default and beginners aren't accustomed to that. If you ask me I'd say beginners shouldn't need to worry about it yet, they're still focused on learning, well, the basics. Like using their editor of choice, or basic Python syntax.
Thanks, I think I'm going to go with the standard installer and then use Poetry, looks like a good tool. I've been using VS Code for a while, and plan to stick with it. Love some of the add-ons!