[Pythonmac-SIG] newbie osx question

Russell E Owen owen@astro.washington.edu
Thu, 19 Dec 2002 08:08:41 -0800


>i've been running basic python scripts (hello world and some other 
>starters) in the terminal with no problem. when i save the code out 
>as a .py file and try and 'run in terminal' from bbedit, i get
>'[bsmith:~] bsmith% /usr/local/bin/python '/Users/bsmith/pyscripts/dice.py'
>/usr/local/bin/python: Command not found.
>[bsmith:~] bsmith% '

I suspect the problem is that your files have Mac line endings. The 
unix python that comes with MacOS X (/usr/bin/python) wants only unix 
line endings. BBEdit can be configured to save files either way (or 
with DOS line endings) by default -- look through the preferences. 
Also, you can trivially change a specific file -- look through the 
toolbar icons at the top of the document, change the setting and save 
the file.

The line ending thing is quite a headache -- one of the little 
problems with trying to combine MacOS and unix to make MacOS X. 
Fortunately iIt'll be fixed in Python 2.3, but that'll be awhile in 
coming out, so meanwhile you should just make sure all your Python 
test code has unix line endings.

An alternative: download and install MacPython. You don't use it from 
a terminal command line; it has a nice IDE and is flexible about line 
endings the way Python 2.3 will be. It also allows you to easily 
create drag-and-drop applications -- a very handy thing to have on 
MacOS X!

-- Russell