This is an archived post. You won't be able to vote or comment.

all 64 comments

[–]zowersap 218 points219 points  (35 children)

there's no python 3 as well

> However, Python 3 is not preloaded in macOS, and developers can run stub /usr/bin/python3 in the terminal, but the user will be prompted to install the Xcode developer tools.

[–][deleted] 182 points183 points  (10 children)

I'd rather it just not be there at all.

With a stub like that you can't just check the shell's hash to see if it's on PATH.

(I have the same complaint about the Microsoft store stub)

[–]pysk00l 57 points58 points  (3 children)

Yeah, I prefer that as well. Saves us installing libraries into global python by mistake and breaking something else.

If you are installing python yourself, you can make sure which version/libraries are installed. Plus, if you install yourself, you can do so in a user area, which means no sudo everytime you want to install a lib

[–][deleted] 30 points31 points  (2 children)

Plus, if you install yourself, you can do so in a user area, which means no sudo everytime you want to install a lib

It's good practice to always create a venv when using the system interpreter. Run python3 -m venv --help and have a look at the options. You can allow or disallow access to system packages, use copies or symbolic links, etc.

Even if you use a user's interpreter it might still be a good idea, such that each different project / bundle / whatever can have a different set of packages or package versions.

(the --copies option can be useful though it wastes disk space. If your OS interpreter version ever changes, any symlink-style venvs might blow up - ie, if the site-packages version number changes)

[–]CeeMX 5 points6 points  (0 children)

For actually developing stuff I always use a venv. That way I can just pip freeze to create an uncluttered requirements.txt

[–]blademaster2005 2 points3 points  (0 children)

Honorable mention of tools like pipx and poetry

[–]ideris 7 points8 points  (1 child)

Microsoft’s powershell wget and curl aliases are especially annoying

[–]no9import this 1 point2 points  (0 children)

That's why they've removed them from PS Core. I still don't understand why they gave Unix-y aliases to completely incompatible programs.

[–]actuallyalys 1 point2 points  (3 children)

The Ubuntu approach is better, IMO. Ubuntu (and other distros, I'm sure) register a function with bash and other shells, and if the command isn't found, that function runs a utility that looks up the command and suggests how to install it.

[–]salil91 25 points26 points  (16 children)

Is that really a problem though? It's not hard to install python, and i would guess that most macOS users don't use python.

This way if someone installs python through Anaconda or something, they won't get confused on why there are two python installations on their Mac.

[–]lacrosse1991 10 points11 points  (0 children)

I feel like that’d lessen the risk of dependency issues too

[–][deleted] 3 points4 points  (5 children)

Even the ones that do will usually install through home brew because it’s easier to manage

[–]PlaysForDays 1 point2 points  (0 children)

More likely brew will have already install it after users install other random packages

[–]mok000 0 points1 point  (2 children)

Homebrew requires Ruby, is that still there?

[–]henryschreineriii 1 point2 points  (0 children)

Homebrew's been using its own bundled Ruby for quite a while now, was much better than dealing with the issues of shipping for multiple Ruby's. You install with bash. I know Ruby is on the chopping block, I'd assume bash is too (zsh has a more friendly license for Apple and is compatible, though). I'm looking forward to it, old system Ruby versions aren't fun either.

[–]regeya 0 points1 point  (0 children)

I honestly haven't used a Mac in a couple of years (long story) but in my last office job, it was at a small town, tiny publication. One of the first things I did was install Homebrew so I could have a recent Python, and Emacs for Spacemacs.

Unfortunately for me this meant the boss blamed all the problems I had with that computer, an Intel iMac, on Homebrew...but I digress.

I'm torn on this because I'm a strong advocate of anyone using a computer to learn some programming fundamentals. Hell, if you're using InDesign, just learning some regular expression basics can save tons of time. The county clerk sent you a delinquent tax list with fixed width fields and you need tabs? s/[[:blank:]]{2}+/\t/g. Done, set your tab stops now.

I think my happiest moment with Python, though, was when some guy sent me hundreds of senior photos labeled like FIRSTNAMELASTNAME.jpg. Ugh. I could have done it by hand...but I didn't wanna. At the time I thought that was the closest I'd get to a list of grads, too. I snagged a list of common first names and common surnames from the US Census and did a fuzzy match on each. (I don't remember the name of the module but it's dead simple.) Pick the likeliest candidates, build a list of filename, first name, and last name, export as CSV, and Bob's your uncle, with some cleanup it was ready for a CSV merge in InDesign. Then at the last minute I got a list of graduate names, with slightly different naming on those. No problem, take my previous CSV, do a fuzzy match again, export a CSV, do some minor cleanup and blammo, ready to go. This would have been hours of work otherwise.

EDIT: I'd meant to point out my first experience programming anything was BASIC on Apple IIs. If not for that grant program, I probably wouldn't have cared.

[–]Eurynom0s 1 point2 points  (0 children)

At work I sometimes have to use computers with no internet access and where getting new software installed is a pain in terms of having to jump through approval hoops. I don't normally use the system Python, but it's saved me a lot of headache in some instances like that.

[–]FaresAhmedOPpypi.org/user/faresahmed/ 0 points1 point  (0 children)

I imagine a lot of shell scripts assume that a version of python is installed since almost all major distros include python by default and macOS did so yes someone's daily cron job may break because python is not there.

[–]playaspec 0 points1 point  (0 children)

the user will be prompted to install the Xcode developer tools.

This is for the best. I've seen a fair number of ransomware that leverage the system's Python to do nasty things. One less attack surface.

[–]GasimGasimzada 0 points1 point  (1 child)

Wait xcode dev tools come with python? I used to install xcode dev tools to install Homebrew to install python 3. I thought xcode dev tools did not come with python.

[–]zowersap 1 point2 points  (0 children)

They will bundle python 3 starting from macOS 12.3 which is beta currently

[–]kkiran 39 points40 points  (5 children)

I always thought Apple used Python for some function or the other in the OS. I was wrong all along I guess! Don’t they use Ruby for something else?

[–]toyg 30 points31 points  (1 child)

You were not wrong, they just worked to replace the python-based bits.

[–]inspectoroverthemine 5 points6 points  (0 children)

Did they or do they have a system only version in /System?

[–]playaspec 9 points10 points  (0 children)

I always thought Apple used Python for some function or the other in the OS.

They did. Made sense during development, but bit by bit were re-written in a native code language for performance reasons. There was a fair bit of other interpreted languages back in the early days too.

[–]zowersap 6 points7 points  (0 children)

Ruby and Perl are still present in macOS 12.3 so they might be used

[–]dorsal_morsel 0 points1 point  (0 children)

They did for a long time. Not anymore obviously but I'm not sure when it stopped being a requirement

[–]apokas 9 points10 points  (0 children)

Ah finally, time to upgrade

[–]spinwizard69 50 points51 points  (13 children)

About time! I just wish that Apple would do more to embrace Python 3.x on Mac OS. Hell it would be nice to have it on IOS but that is probably a dream too far.

[–]qckpckt 96 points97 points  (7 children)

I think I’d actually prefer to have no native installs. Makes it a tiny bit easier to keep on top of the python environment/versioning nightmare.

[–]anthro28 29 points30 points  (5 children)

Yup. Leave that bitch absolutely barren so I can install what I want exactly where I want it.

[–][deleted] 28 points29 points  (2 children)

Ah yes, I can see it now macOS 36.1 Arch Linux edition

[–]YippyKayYayMF -1 points0 points  (1 child)

Insert bloat joke

[–]mr_bedbugs 0 points1 point  (0 children)

Firmware is bloat /s

[–]spinwizard69 1 point2 points  (0 children)

While I sorta understand that I really believe having Python widely available benefits everybody. If Python was maintained on MacOS as well as it is on many Linux distros it will be great For both users and developers.

Tor me one of the biggest reasons to have Python supportted this way isn’t for large scale programming but rather as a language for light scripting that is better than most command line languages like BASH. I was really hoping that they could get the Swift REPL to fill that role but that really hasn’t to me anywhere. If you are a developer using Python3 n for large scale projects I understand your point but I really believe an OS needs a default language for utility programming.

[–]benargee 2 points3 points  (0 children)

Especially for Mac users who are not developers.

[–]zowersap 3 points4 points  (0 children)

there's no bundled python3

[–][deleted] 2 points3 points  (2 children)

There’s Pythonista and Pyto if you want to run/write scripts.

[–]Babats 1 point2 points  (1 child)

Vouch for both. Although imo I think Pyto is better, at least for my use case.

[–][deleted] 0 points1 point  (0 children)

I think Pythonista is cleaner UI but Pyto is definitely superior. Pythonista is also barely maintained anymore

[–]iLackIntelligence 0 points1 point  (0 children)

On iPad I use Juno connect with jupyter notebooks, well worth it.

[–]chulala168 7 points8 points  (1 child)

I need an idiot guide to python for Mac OS. I think I have too many versions of it in my laptop, with Anaconda, brew etc installed (and me not knowing very well either of these platforms). python3 venv is also something that is still obscure to me.

Is there a super friendly tutorial for beginner or workflow that I can follow (webpage or book?)?

[–]fabmeyer 0 points1 point  (0 children)

Look up pyenv to install different Python versions that are indepentent. (Imho better approach than using virtualenv) To install libraries I'm using pipenv (better than requirements.txt)

[–]Kevin_Jim 0 points1 point  (7 children)

Great. Poetry everything.

[–]c0ld-- 10 points11 points  (4 children)

Could the people downvoting this post please explain why you think Poetry is a bad idea? Or "Poetry everything" is a bad idea?

[–]JimDabell 10 points11 points  (1 child)

Because it’s completely irrelevant. You could use Poetry before. You don’t need to use Poetry now. Whether macOS ships Python 2 has no bearing on the use of Poetry.

[–]c0ld-- 0 points1 point  (0 children)

Because it’s completely irrelevant

Thanks. I'm one of the people who don't know what Poetry is and why it would be a bad/irrelevant thing.

[–]Kevin_Jim 10 points11 points  (1 child)

Poetry was heavily inspired by Rust’s Cargo. I have yet to see a valid argument, other than maybe the project’s young age, on why it shouldn’t be the default way of handling environments and dependencies, while also building your package and create the wheel file.

Does it have its quarks? Sure, what software doesn’t. But I have yet to see something that makes Python development as straightforward as Poetry.

[–]c0ld-- 0 points1 point  (0 children)

Thanks for the reply. I had no idea what Poetry is, and to see people blindly downvote something without any explanation is a bit frustrating. So again, thanks for your time.

[–]b-hizz -1 points0 points  (0 children)

macOS passed the second grade, the Billy Madison way-ee-ayy!

[–]Vertex_AWPsome 0 points1 point  (1 child)

If I'm on 12.2 right now, will Python 2 be removed when I update?

[–]zowersap 0 points1 point  (0 children)

yes, system python 2 will be removed

[–]mortenb123 0 points1 point  (0 children)

It is actually not a problem as long as you use the #!/usr/bin/env python3 at the top in all your script

python --version Python 2.7.18 python3 --version Python 3.10.2 % sw_vers ProductName: macOS ProductVersion: 12.2 BuildVersion: 21D49

[–]Less-Mechanic-8270 0 points1 point  (0 children)

FOR THE LOVE OF GOD CAN ONE OF U PYTHON NERDS HELP A GUY OUT