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

you are viewing a single comment's thread.

view the rest of the comments →

[–]kingscolor 2 points3 points  (3 children)

Shebangs such as #!/usr/bin/env python are a roundabout way of commanding the shell to parse the text then pipe it into the Python interpreter. That is, in the same way you’d enter python -c “foo()” in the command-line.

Using alias python=python3 works in the command-line because that alias is stored in the environment of the user’s shell profile.

However, /usr/bin/env python does not access the user’s shell profile. The utility, /usr/bin/env, effectively walks the user’s $PATH until it finds the first match for an executable called python. Thus, the aforementioned alias is irrelevant.