alfred-workflow icon indicating copy to clipboard operation
alfred-workflow copied to clipboard

Not working on the latest MacOS 12.3

Open wisinfun opened this issue 2 years ago • 11 comments

First of all, thank you. Not working on the latest MacOS 12.3

wisinfun avatar Mar 12 '22 07:03 wisinfun

I think Apple finally removed python2.7 from macOS since the command python cannot be found by Alfred.

~~edit: Migrating the workflow library with 2to3 and using python3 in my Script Filters, did the trick to revive my workflows: https://github.com/fedecalendino/alfred-workflow/commit/650e193cda80e3fe16cb7fcbfa805e71371f6d93~~

~~Although they are quite simple, so it might not work for everyone as well.~~

fedecalendino avatar Mar 14 '22 20:03 fedecalendino

It's especially ironic given the text:

Alfred-Workflow is targeted at the system Python on macOS. Its goal is to enable developers to build workflows that will “just work” for users on any vanilla installation of macOS since Snow Leopard.

Yeah, well, for some time it's been obviously that Python2 was going away. For it to "just work" now, it needs python 3 support.

at the bottom of https://www.deanishe.net/alfred-workflow/supported-versions.html#why-no-python-3-support

psifertex avatar Mar 15 '22 19:03 psifertex

For anyone else in the same boat, might want to check out this fork: https://github.com/NorthIsUp/alfred-workflow-py3

(found via the pinned issue: https://github.com/deanishe/alfred-workflow/issues/97)

psifertex avatar Mar 15 '22 19:03 psifertex

macOS has removed the python2.7. You need to follow the steps to solve your problem:

First, you need to reinstall Python 2. To do so, install Homebrew then run the following in a terminal:

export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
eval "$(brew shellenv)"
brew install pyenv
pyenv install 2.7.18
ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" "${HOMEBREW_PREFIX}/bin/python"

Now you can use "python filename.py" to run your python2 file in the macOS terminal. You can also run your python2 code in the Alfred Script Filter.

But if you use bash to run your python2 file in Alfred, you need to do one more thing. Change your bash command in your workflow configuration from: python filename.py "{query}" to: ${HOME}/.pyenv/versions/2.7.18/bin/python filename.py "{query}" If you don't do this you will get an error report by Alfred debugger which is "/bin/bash: python: command not found"

moneygalaxy avatar Mar 16 '22 19:03 moneygalaxy

Here's Apple's release notes on the subject. Namely:

Python 2.7 was removed from macOS in this update. Developers should use Python 3 or an alternative language instead.

See also, this Stack Exchange thread

xavdid avatar Mar 17 '22 03:03 xavdid

It's especially ironic given the text:

Alfred-Workflow is targeted at the system Python on macOS. Its goal is to enable developers to build workflows that will “just work” for users on any vanilla installation of macOS since Snow Leopard.

Yeah, well, for some time it's been obviously that Python2 was going away. For it to "just work" now, it needs python 3 support.

at the bottom of https://www.deanishe.net/alfred-workflow/supported-versions.html#why-no-python-3-support

I agree with you, the sentence you quoted is ridiculous. Even if the developers stick to their views, they should be prepared for python3 in another branch. "just work" can become "just not work" in one night, now, it happens and no official "just work" solutions.

FischLu avatar Mar 18 '22 12:03 FischLu

macOS has removed the python2.7. You need to follow the steps to solve your problem:

First, you need to reinstall Python 2. To do so, install Homebrew then run the following in a terminal:

export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
eval "$(brew shellenv)"
brew install pyenv
pyenv install 2.7.18
ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" "${HOMEBREW_PREFIX}/bin/python"

Now you can use "python filename.py" to run your python2 file in the macOS terminal. You can also run your python2 code in the Alfred Script Filter.

But if you use bash to run your python2 file in Alfred, you need to do one more thing. Change your bash command in your workflow configuration from: python filename.py "{query}" to: ${HOME}/.pyenv/versions/2.7.18/bin/python filename.py "{query}" If you don't do this you will get an error report by Alfred debugger which is "/bin/bash: python: command not found"

and you should replace '/usr/bin/python' -> '/usr/local/bin/python' in /workflow/background.py

raingao avatar Mar 18 '22 12:03 raingao

I also don't get why we didn't have a version of the code that would work on both version of Python, plenty of libraries do that.

fedecalendino avatar Mar 18 '22 12:03 fedecalendino

I faced the same issue a few weeks ago and decided to bite the bullet and migrate all my workflows to Dart because it can be compiled into a standalone executable eliminating the need for any external prerequisites.

In the process, I had to build a library just like this one in Dart. The Alfred docs helped a lot. Was a lot of work but fun 😊

techouse avatar Mar 20 '22 14:03 techouse

See https://github.com/deanishe/alfred-workflow/pull/183

devnoname120 avatar Mar 23 '22 20:03 devnoname120

macOS 已移除 python2.7。您需要按照以下步骤解决您的问题: 首先,您需要重新安装 Python 2。为此,请安装 Homebrew,然后在终端中运行以下命令:

export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
eval "$(brew shellenv)"
brew install pyenv
pyenv install 2.7.18
ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" "${HOMEBREW_PREFIX}/bin/python"

现在您可以使用“python filename.py”在 macOS 终端中运行您的 python2 文件。您还可以在 Alfred 脚本过滤器中运行您的 python2 代码。 但是如果你使用 bash 在 Alfred 中运行你的 python2 文件,你还需要做一件事。将工作流配置中的 bash 命令从:python filename.py "{query}"更改为:${HOME}/.pyenv/versions/2.7.18/bin/python filename.py "{query}"如果您不这样做,您将收到 Alfred 调试器的错误报告,即“/bin/bash: python: command not found”

你应该在 /workflow/background.py 中替换 '/usr/bin/python' -> '/usr/local/bin/python'

非常感谢!解决了我的问题!

xieao100 avatar Jul 21 '22 10:07 xieao100