osx - "python myscript" ignores "#!/usr/bin/env pythonX" where pythonX doesn't exist -
why doesn't test.py throw error env: python3: no such file or directory when python 3 not installed?
my system (mac os x) has python 2.7 installed, not python 3:
$ /usr/bin/env python -v python 2.7.12 $ /usr/bin/env python3 -v env: python3: no such file or directory file test.py:
#!/usr/bin/env python3 import sys print sys.executable executing test.py:
$ python test.py /usr/local/opt/python/bin/python2.7 i thought since python 3 not exist on system, having shebang line #!/usr/bin/env python3 throw error , terminate script. env selected python 2.7 interpreter.
the shebang interpreted os when tries execute script. whey type python test.py, os executes python , python executes script (and python found based on current path) opposed being processed os.
if make script executable (chmod +x test.py) , try execute directly (e.g. ./test.py), os responsible running script @ shebang figure out program responsible run script. in case, /usr/bin/env python3 , try use that. since python3 isn't there (or not findable on path) you'll see error.
Comments
Post a Comment