Jump to content

Python-based workflows stopped working (on Mac)

Recommended Posts

Recently, all my workflows that rely on Python scripts stopped working – instead the workflows send me to the fallback (web search). This tells me that the problem is not in the workflow but in summoning Python and running the script.


Example: WordSearch (https://github.com/isaacpz/Alfred-WordSearch) and "syn" workflow that searches for synonyms for a queried word, e.g., "syn error" should give mistake, etc. Now it sends me to fallback web search. Syn simply runs the following in bash: "python similar.py ml "{query}".


I can see that it is a relative path to "similar.py" – is that the problem (all Python workflows use this)? Something with PATH? The Python install? I'm not sufficiently Python-savvy to figure this out, but it used to work – and I have tried updating python. "python -V" in terminal gives me "Python 3.9.12".


Any thoughts? Thanks!



Link to comment
29 minutes ago, cynicaljoy said:

Just realized that Alfred will find "python" in /usr/local/bin:


 ln -s /usr/local/bin/python3 /usr/local/bin/python 


It will, but you should not make that link. Workflows expect Python 2 at that location, not 3, and they are often incompatible.

Link to comment

Thanks for pointing me to the general solution/root of the issue. 


Unfortunately, I still can't make it work, even after trying a lot of different suggestions including following the official Alfred advice (https://www.alfredapp.com/help/kb/python-2-monterey/), installing and setting up pyenv. And I have tried reinstalling several workflows, including Convert (https://github.com/alfredapp/updated-third-party-python2-workflows) afterwards.


Then, I have tried pointing bash to the pyenv 2.7 version instead of the also installed 3.9.12 (including by following the last advice here https://stackoverflow.com/questions/15285592/how-to-set-default-python-version-in-terminal-on-os-x-10-6-8). Now, when I write "python -V" in a fresh terminal session, it does show Python 2.7.18. But the workflows still don't work.


My hunch is that it is because I have several Python versions installed (and installed in different ways including via Homebrew and via pyenv).


Is there anything I can re-/uninstall or something to make things work (e.g., Python, pyenv, Alfred), I wonder? 


Link to comment

     which python -> "python: aliased to /Users/USERNAME/.pyenv/versions/2.7.18/bin/python2.7"
    /usr/local/bin/python --version -> "zsh: no such file or directory: /usr/local/bin/python"
    ls -l /usr/local/bin/python -> "lrwxr-xr-x  1 USERNAME  admin  7 May  2 14:08 /usr/local/bin/python -> python2"
    /opt/homebrew/bin/python --version -> "zsh: no such file or directory: /opt/homebrew/bin/python"
    ls -l /opt/homebrew/bin/python --version -> "ls: --version: No such file or directory             ls: /opt/homebrew/bin/python: No such file or directory"


Link to comment

Then try:

  • rm /usr/local/bin/python
  • ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" '/usr/local/bin/python'

And it should start working. If it doesn’t, please post the output of both those commands, plus the (new) outputs of:

  • /usr/local/bin/python --version
  • ls -l /usr/local/bin/python

Link to comment

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...