Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Ascii vs. Utf-8 when Running Shell Scripts in Automator...?

I am trying to run ocrmypdf (a command-line implementation of Tesseract) in Automator (currently as a workflow, and once debugged, as an app). I can run ocrmypdf in termal, but in Automator, I get an error stating:


"RuntimeError: ocrmypdf will abort further execution because Python 3 was configured to use ASCII as encoding for the environment."


I have adapted instructions from another shell script. The ocrmypdf version reads:


for f in "$@"

do

suffix="-eng-ocred.pdf"

base=`basename "$f" .pdf`

outputfile=$base$suffix

/usr/local/bin/ocrmypdf --force-ocr "$f" "$outputfile"

done


Some online sources suggest using environment variables LC_ALL and LANG; in this case both would be en_US.UTF-8 but I couldn't get these to work, and other sources state these are specific to Linux proper and don't work in MacOS.


Any idea how to avoid this bug in automator?


If I can get this fixed, I will probably set up different apps for different languages. I don't know how to query myself for the appropriate language.

MacBook Air (11-inch Mid 2013), macOS Sierra (10.12.6)

Posted on Mar 9, 2018 2:51 PM

Reply
Question marked as Best reply

Posted on Mar 10, 2018 11:40 AM

Hi Marja,


In the Terminal, the locale(1) command will show everything set as "en_US.UTF-8," or your localized country code. In the Automator Run Shell Script, locale will report "C."


Try setting export LANG=en_US.UTF-8 (or your appropriate country code) at the beginning of your Run Shell Script action, and see if ocrmypdf sniffs out that environment variable setting, and tells Python to do UTF-8 instead of ASCII.

1 reply

There are no replies.

Ascii vs. Utf-8 when Running Shell Scripts in Automator...?

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