Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using OSX Automator, Python, and BeautifulSoup

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.

like image 724
mmk Avatar asked May 17 '26 09:05

mmk


1 Answers

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
like image 66
mmk Avatar answered May 20 '26 01:05

mmk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!