尝试在Mac上运行python脚本时出现连续错误

时间:2015-08-22 18:08:02

标签: python macos

对python来说很新,所以我确定它可能是愚蠢的。试图在我的Mac上运行https://github.com/aesptux/download-reddit-saved-images。我用pip安装了所有要求:

beautifulsoup4>=4.3.2
praw>=2.1.17
requests>=2.3.0
PyYAML==3.10
Pillow==2.4.0

然后配置config.yaml并尝试运行脚本。它返回此错误:

/Users/dp/Dev/download-reddit-saved-images/script.py: line 3: 
Python script to download saved images from reddit
: command not found
from: can't read /var/mail/__future__
/Users/dp/Dev/download-reddit-saved-images/script.py: line 5: import: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 6: import: command not found
from: can't read /var/mail/glob
from: can't read /var/mail/bs4
from: can't read /var/mail/zipfile
from: can't read /var/mail/PIL
/Users/dp/Dev/download-reddit-saved-images/script.py: line 11: import: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 12: try:: command not found
from: can't read /var/mail/io
/Users/dp/Dev/download-reddit-saved-images/script.py: line 14: except: command not found
from: can't read /var/mail/StringIO
/Users/dp/Dev/download-reddit-saved-images/script.py: line 16: import: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 17: import: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 20: __author__: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 21: __version__: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 22: __contributor__: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 24: IMAGE_FORMATS: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 25: pcd,: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 26: tiff,: command not found
/Users/dp/Dev/download-reddit-saved-images/script.py: line 28: syntax error near unexpected token `('
/Users/dp/Dev/download-reddit-saved-images/script.py: line 28: `CONFIG = open('config.yaml')'

我不知道从哪里开始进行故障排除。

1 个答案:

答案 0 :(得分:0)

它作为shell脚本而不是Python脚本运行。尝试:

<div class="form1btn">
  <input type="button" value="" id="mcodebtn">
</div>

Paulo Almeidacomment中提供的解决方案,但他还没有将其作为答案。