Your file has Windows line endings, which unix shells don't like.
Just convert them to Unix file endings using dos2unix aaa.py
(you may need to install dos2unix
, which is a very light [200kB] but useful software) and you should be fine.
Different line endings representations are a common source of "strange" problems. You can check line endings with file <yourfile>
if it says something like:
<yourfile>: ASCII text, with CRLF line terminators
It means it has Windows line endings and you should convert them to unix, using dos2unix
, the vim command :set ff=unix
or your favourite text editor if it has the feature (many do).
/usr/bin/python
, and not/usr/bin/env python
?python aaa.py
or already simplypython
?python aaa.py
?^M
after thepython
in the shebang line. This is probably a remnant of having edited the file on a non-Unix machine (typically, Windows). Delete that char and it will work --- if you had cut and pasted that error in the question, without screenshots, you have had the answer instantly...