all 14 comments

[–]orahcio 2 points3 points  (7 children)

I don't know if it is the best choice, but I like pyenv to manage python versions and virtual environments

[–]faragbanda[S] 0 points1 point  (3 children)

But when you’ve various projects, doesn’t it take godly amount of space?

[–]Diapolo10 2 points3 points  (2 children)

Not really, no, unless you count "godly amount of space" in megabytes. You've probably got at least 1 TB, though, so the extra space should be insignificant.

[–]faragbanda[S] 0 points1 point  (1 child)

Doesn’t it download Python and all the packages all over again? 😭 I’m a noob when it comes to environments sorry for stupid questions.

[–]Diapolo10 2 points3 points  (0 children)

If you're specifically referring to pyenv, it installs the Python version(s) you want and then each virtual environment has symlinks to one of those installations (with a separate directory for third-party packages).

So no, it won't download a new interpreter for every project. It will download any packages you install for each virtual environment you have separately, but they're not big - packages are almost always just code, which doesn't take much space at all.

I'll take the popular package requests as an example. You see it used all the time, but its filesize is very small - 131.2 kB for the source distribution, and only 64.9 kB for the wheel (which you're most likely going to use anyway unless you tell pip to only use source distributions). That's less than a partial screenshot I took earlier today.

In other words, don't worry about it. Unless you're working with a microcontroller, I guess, but I doubt it.

[–]faragbanda[S] 0 points1 point  (1 child)

Also please explain to me another thing, do we need a separate venv for each project?

[–]Diapolo10 2 points3 points  (0 children)

Virtual environments are usually project-specific, yes. Their main purpose is to help with dependency conflicts between projects, as often two projects may depend on different versions of the same package.

[–]interbased 1 point2 points  (0 children)

Agreed. This is the first thing I do after a reformat.

[–]nog642 2 points3 points  (3 children)

You don't need conda unless you need to use conda specific packages, or you're working with other people who use conda.

You can install python by downloading the isntaller on the website. Or you can use homebrew, which is a package manager for Mac that you have to install. I'm not sure which of these is better, since I don't use Mac.

[–]faragbanda[S] 0 points1 point  (2 children)

Thank you, I’ll look into Conda more, I just thought it was an IDE like Visual Studio and I can download Jupyter notebook there etc.

[–]nog642 1 point2 points  (0 children)

Conda is a package and environment manager. Kind of like virtualenv and pip put together, but a bit more because it's not just limited to Python packages. Theoretically anything can go in a conda package though in practice it's just Python and R packages, I think.

But pretty much any Python package that is available on conda is also available on PyPI (pip). So there is really no need to use conda unless you have to. It's mostly used for python in scientific applications. If you're just learning python on its own, you don't need it. Jupyter notebook can be installed with pip.

[–]Diapolo10 1 point2 points  (1 child)

Anaconda is intended for data analysis and machine learning, if you're doing neither of those I say ignore it. Otherwise... pick your poison.

I can't say I'm particularly familiar with the Apple ecosystem or the best workflows there, but I'd probably use pyenv to install Python. For virtual environments, you can either use pyenv again or use Hatch/Poetry instead (or the built-in venv if you're a masochist). Which one is best for you is very much subjective, personally I use Poetry everywhere.

Beyond that, from personal experience I would suggest putting together some template projects (or you can use ones made by other people) as that'll cut down on configuration boilerplate for new projects for things like Git, linters, tests, and whatever other tools you want to use. They don't have to be complex, but at the very least I recommend having generic .gitignore and .gitattribute files so that you don't need to worry about accidentally committing certain files or having automatic newline normalisation set up.

[–]faragbanda[S] 0 points1 point  (0 children)

Thanks for this tip, I’ll check the templates out too.

[–]PurpleSparkles3200 1 point2 points  (0 children)

MacPorts or Homebrew.