Running Python in Automator

I am trying to make a pic to text code for Python. I run it in Atom(compiler) and it works fine. I run it in Terminal and it runs fine, but I'm trying to do it in automator but it isn't working. Here's the error:


User uploaded file

macOS High Sierra (10.13.2)

Posted on Mar 11, 2018 9:38 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 11, 2018 12:16 PM

In the Run Shell Script action, set the Shell selection to /usr/bin/python.


Python does not implicitly know that your PicToText.py script is in your Documents folder, so you must tell it with (the following is all one line and may wrap):


(cd ~/Documents;source ~/.bash_profile;python -d -c ./PicToText.py) > ~/Desktop/PicToText.log

34 replies

Mar 11, 2018 11:43 AM in response to VikingOSX

Ok so I'm having the screenshot save the picture file in Documents(where my PicToText.py is) and then as soon as that's done I want to have the Python Code to run. (So do I use arguments or stdin). Sorry I am so new to this I've had Mac for a few days but want to get this working. So then after I change that setting what will I enter into the ShellScript? Here is my code:


User uploaded file

Mar 11, 2018 2:48 PM in response to VikingOSX

It's taking a certain screenshot to a .png file that the python code will then take and turn into text. That part is working fine. Ok so i did

(cd ~/Documents && /usr/bin/python -d -c ./PicToText.py) &> ~/Desktop/scriptlog.txt


and now all its telling me is "The action "Run Shell Script" encountered an error." and thats it. Its not telling me what or where the problem is.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Running Python in Automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.