Running Python in Automator
macOS High Sierra (10.13.2)
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
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:
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.
do shell script "cd ~/Documents;python -d -c PictoText.py"
Yeah so when I run the code in Atom or do "python /Users/maanavmodi/Documents/PicToText.py" in Terminal my helloworld.txt changes based off the screenshot I did in Automator,
No I don't believe it is even running the code in the Shell Script. I keep getting errors as seen above.
I can dispute what you believe about tilde with this one line in a Run Shell Script action using bash as the shell selection:
echo ~ &> ~/Desktop/foo.txt
Things must changed. I had a problem when working with files when writing a script in 10.4, Tiger.
R
Well I'm thinking about just sticking with Shell Script. I'm just so new to automator. I really just need to know what to enter.
I think I'm sticking to Shell Script. But if you can get it to work with applescripts that would also work!
Yeah i put #!/usr/bin/python as my first line and everything it still isn't working. It's not even telling me any error reasons just error.
I did this and no error(yay?) but it didn't change my HellowWorld.txt file like it shouldve.
Running Python in Automator