3

I'm new to Python, and having an issue trying to use Automator in OS X 10.8 to run a Python script that uses Beautiful Soup.

This script runs just fine in Terminal, and other scripts that don't involve Beautiful Soup work just fine for me in Automator using the exact same commands -- but when I try to use Automator to run this script or any other that includes the line from bs4 import BeautifulSoup, it returns an error message.

A popup appears with the message 'The action “Run Shell Script” encountered an error. Check the actionʼs properties and try running the workflow again.' The Automator log says 'Run Shell Script failed - 1 error; Traceback (most recent call last):'

It's probably something that should be obvious to me if I understood more about the Python ecosystem, but I've searched and found no answers. In Automator I'm using the "Run Shell Script" action, using the /bin/bash shell, passing inputs to stdin, and entering the following commands (all of which works for other non-BeautifulSoup scripts):

cd desktop
python script.py

I'm on OSX 10.8, Python 2.7, and BS4.

4

1 回答 1

5

After some more head banging and digging I found a functional hack here. It seems that by default Automator was calling a different installation of Python than Terminal does. By specifying the proper installation in the "Run Shell Script" code I got the script to run properly:

cd desktop
/Library/Frameworks/Python.framework/Versions/2.7/bin/python script.py
于 2013-04-01T16:01:56.660 回答