[Tutor] python scripting using "./"

Joel Goldstick joel.goldstick at gmail.com
Tue May 24 15:30:28 CEST 2011


On Tue, May 24, 2011 at 9:10 AM, Hank Wilkinson <hwilkinson at triad.rr.com>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
>

do you have this in first line of your file:

#!/usr/bin/env python

in your path you have /usr/bin.  if you go there you will probably see a
directory with python executable in it.




-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110524/be0cf4c8/attachment.html>


More information about the Tutor mailing list