Jump to content

Using Python 3 from the languages dropdown


Recommended Posts

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?

 

image.png.24b26f05ca6018ecaba22511871d8ea1.png

 

Link to comment

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.

Link to comment

@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. :)

Link to comment
  • 5 months later...

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 changed the title to Using Python 3 from the languages dropdown

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...