[Tutor] python scripting using "./"

Christian Witts cwitts at compuscan.co.za
Tue May 24 15:29:32 CEST 2011


On 2011/05/24 03:10 PM, Hank Wilkinson wrote:
> I am trying to do script in python using "./"
> Here is a session showing "bad interpreter: No such file or directory"
> Is this a python question/problem?
>
> Last login: Sat May 21 14:22:49 on ttys000
> John-Wilkinsons-iMac:~ wilkinson$ cd /Users/wilkinson/Documents/py32/p31summerfield
> John-Wilkinsons-iMac:p31summerfield wilkinson$ pwd
> /Users/wilkinson/Documents/py32/p31summerfield
> John-Wilkinsons-iMac:p31summerfield wilkinson$ ls hello.py
> hello.py
> John-Wilkinsons-iMac:p31summerfield wilkinson$ python hello.py
> Hello World!
> John-Wilkinsons-iMac:p31summerfield wilkinson$ chmod +X hello.py
> John-Wilkinsons-iMac:p31summerfield wilkinson$ ./hello.py
> -bash: ./hello.py: /usr/local/bin/python3.1^M: bad interpreter: No such file or directory
> John-Wilkinsons-iMac:p31summerfield wilkinson$ echo $PATH
> /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
> John-Wilkinsons-iMac:p31summerfield wilkinson$ cat hello.py
> #!/usr/local/bin/python3.1
>
> print("Hello", "World!")
> John-Wilkinsons-iMac:p31summerfield wilkinson$ python
> Python 3.1.2 (r312:79147, Mar 20 2011, 17:15:01)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> sys.path
> ['', '/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python31.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1', '/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib-dynload', '/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages']
>
> Thank you.
> Hank
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Where is the python binary actually located ? You can check with `which 
python` to find the location, mine was always /usr/bin/python with *nix, 
can't say off-hand the location with Mac.

-- 
Christian Witts


More information about the Tutor mailing list