简体   繁体   中英

Continual errors while trying to run python scripts on Mac

Pretty new to python, so I'm sure it's probably something stupid. Trying to run https://github.com/aesptux/download-reddit-saved-images on my Mac. I installed all the requirements with pip:

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

then configured config.yaml and tried to run the script. It returns this error:

/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')'

I have no idea where to start troubleshooting from here.

It's running as a shell script rather than a Python script. Try:

python script.py

Solution provided by Paulo Almeida in a comment but he hasn't put it as an answer yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM