Why usr bin env python




















It sounds like you may have been running your script in a way that ignores the shebang line, such as python script. I would actually prefer not to use env. Using env says to run the script with your preferred Python interpreter, which may not be the interpreter the code requires. The Python installer pip , setup.

That is, it's the job of the installer, not the runner, to make sure the correct interpreter is available. Add a comment. Active Oldest Votes. The long answer for bash : let's imagine your python file is named 'tst. It seems bash requires absolute paths for command, whereas zsh accepts relative paths as well. So for zsh only! Improve this answer. Interesting, in arch it finds the relative path just as if I will execute python from my terminal and!

Blasco Yes Indeed this is interesting. It might not be the OS, but the shell which reacts differently. Whatever in order to be as interoparable as possible it still seems to be best to use! Makes sense, it's the answer I was looking for, I thought it might work with all shells. I'm using zsh. I add this to my answer as answers are more presistent than comments — gelonida. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

More on env is to be found here , and, as always, in man env from a terminal. In a comment, it was asked why we cannot simply use! The reason is that an executable is executed by execve , as we can read here. Specifically the lines:. An interpreter script is a text file that has execute permission enabled and whose first line is of the form:. The interpreter must be a valid pathname for an executable That makes sense, since scripts in any language can e.

Skip to content python scripts. For Windows users, it is easy to conflate env with Python virtual environments as opposed to the env tool in Linux. The following Migration bullet in the PEP recommends being explicit wherever possible using python3 as opposed to python where intended:.

It is strongly encouraged that distribution-specific packages use python3 or python2 rather than python, even in code that is not intended to operate on other distributions. This will reduce problems if the distribution later decides to change the version of the Python interpreter that the python command invokes, or if a sysadmin installs a custom python command with a different major version than the distribution default.

For something like! That, and the fact that!



0コメント

  • 1000 / 1000