emptysquare Posted April 1, 2022 Share Posted April 1, 2022 I upgraded to Monterey and like many people, my workflows broke because they rely on Python 2. I know how to install Python 2 with Homebrew, but that's not my goal. My goal is to use Python 3 instead. But how do I do that? The Alfred Workflow "Run Script" action has a "Language" dropdown with a fixed set of choices, not including /usr/bin/python3. How can I tell Alfred to use /usr/bin/python3 for the "Run Script" action? Link to comment
vitor Posted April 1, 2022 Share Posted April 1, 2022 45 minutes ago, emptysquare said: How can I tell Alfred to use /usr/bin/python3 for the "Run Script" action? Link to comment
emptysquare Posted April 1, 2022 Author Share Posted April 1, 2022 Thanks, I was afraid that was the answer. Saving my script as a separate file is fine, but less convenient than typing the script directly into the "Run As" dialog. It seems like the "language" dropdown should be configurable, especially since some of its options (like /usr/bin/python) are now obsolete. Blake 1 Link to comment
macsorcery Posted April 2, 2022 Share Posted April 2, 2022 Yes, this is disappointing. Why can't Alfred just add python3 now? Blake and emptysquare 2 Link to comment
Vero Posted April 5, 2022 Share Posted April 5, 2022 @macsorcery Alfred doesn't bundle scripting languages (and didn't bundle Python 2 in the past); It uses the ones made available by macOS or that you've installed yourself. There are instructions on reinstalling Python 2 here, as most workflows are being tweaked to use the new location where Python 2 is located on your Mac: https://www.alfredapp.com/help/kb/python-2-monterey/ Alternatively, some workflow creators are opting to move away from Python altogether and rewriting their workflows using other scripting languages that are built into Alfred and don't require any setup in this respect. Alan He 1 Link to comment
zonegrave Posted September 29, 2022 Share Posted September 29, 2022 This might be a work around. I've tried it and it works quite well for me. You may use the "/bin/bash" script and execute the python3 script inside it. Use the "cat <<EOF" instead of a real file so as to not create an extra file. Here is an example query=$1 cat <<EOF | /usr/bin/python3 import sys query = "${query}" # do something here ... result = ... sys.stdout.write(result) EOF Link to comment
vitor Posted September 29, 2022 Share Posted September 29, 2022 Welcome @zonegrave, That is more complicated than the previously posted solution and could make long code hard to read. Do note neither is necessary now, because Alfred 5 also lists python3 in the dropdown. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now