First program
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Jun 15 03:53:52 EDT 2010
En Sat, 12 Jun 2010 06:03:43 -0300, Phil H <skilphil at gmail.co.za> escribió:
> Trying my hand with Python but have had a small hiccup.
> Reading 'A byte of Python' and created helloworld.py as directed.
>
> #!/usr/bin/python
> # filename : helloworld.py
> print 'Hello World'
>
> At the terminal prompt cd to the file location and run from the prompt.
>
> phil at grumpy:~/projects/python$ python helloworld.py
> Hello World
>
> All fine.
>
> Then I tried the following as described in the tutorial and get the
> following error
>
> phil at grumpy:~/projects/python$ chmod a+x helloworld.py
> phil at grumpy:~/projects/python$ ./helloworld.py
> bash: ./helloworld.py: /usr/bin/python^M: bad interpreter: No such file
> or directory
>
> The permissions are: rwxr-xr-x.
Looks like you created helloworld.py on Windows, or using Windows-oriented
tools (perhaps a samba drive? ftp from a Windows disk?)
Windows text files end each line with the \r\n sequence (CR LF, bytes 0x0D
0x0A, ^M^J). Unix (and Linux) uses only a \n (LF, 0x0A). The \r will be
read as part of the previous line then.
There are tools to convert back and forth those formats (dos2unix and
unix2dos, or the crlf.py demo script in the Python source distribution).
But to avoid problems, it's better to use the right tools for the OS
you're working with (that is, don't use notepad to edit Linux files...)
--
Gabriel Genellina
More information about the Python-list
mailing list