Sample Header Ad - 728x90

What is in `/usr/bin/python3`?

0 votes
0 answers
41 views
I'm on macOS Sequoia 15.3.2, and I've been experiencing some weird behavior with /usr/bin/python3 lately. Usually it seems like a perfectly normal Python 3.9 binary:
$ /usr/bin/python3 --version
Python 3.9.6
But then when I cd into a directory with [use flake](https://github.com/nix-community/nix-direnv) in its [.envrc](https://direnv.net/) file, it suddenly starts pretending like it doesn't exist:
$ /usr/bin/python3 --version
error: tool 'python3' not found
But the _file_ does exist:
$ stat /usr/bin/python3
  File: /usr/bin/python3
  Size: 118848    	Blocks: 24         IO Block: 4096   regular file
Device: 1,14	Inode: 1152921500312496951  Links: 78
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/   wheel)
Access: 2025-03-06 05:06:02.000000000 -0500
Modify: 2025-03-06 05:06:02.000000000 -0500
Change: 2025-03-06 05:06:02.000000000 -0500
 Birth: 2025-03-06 05:06:02.000000000 -0500
Curiously, its first 4 bytes are 0xCAFEBABE, which I thought [was associated with Java](https://stackoverflow.com/a/2808684/5044950) :
$ xxd /usr/bin/python3 | head
00000000: cafe babe 0000 0002 0100 0007 0000 0003  ................
00000010: 0000 4000 0000 7f20 0000 000e 0100 000c  ..@.... ........
00000020: 8000 0002 0000 c000 0001 1040 0000 000e  ...........@....
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
But, naively, I don't see "Java" mentioned anywhere in the binary; that is, this command returns nothing:
$ strings /usr/bin/python3 | grep -i java
**What is in /usr/bin/python3 on macOS?** What kind of binary is it, and why does it print this bizarre "tool 'python3' not found" error message in some situations?
Asked by Sam Estep (101 rep)
Mar 19, 2025, 05:09 PM
Last activity: Mar 19, 2025, 05:35 PM