Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on the latest MacOS 12.3 #182

Open
wisinfun opened this issue Mar 12, 2022 · 11 comments · May be fixed by #183
Open

Not working on the latest MacOS 12.3 #182

wisinfun opened this issue Mar 12, 2022 · 11 comments · May be fixed by #183

Comments

@wisinfun
Copy link

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

@fedecalendino
Copy link

fedecalendino commented Mar 14, 2022

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.

@psifertex
Copy link

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
Copy link

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: #97)

@moneygalaxy
Copy link

moneygalaxy commented Mar 16, 2022

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"

@xavdid
Copy link

xavdid commented Mar 17, 2022

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

@FischLu
Copy link

FischLu commented Mar 18, 2022

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.

@raingao
Copy link

raingao commented Mar 18, 2022

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

@fedecalendino
Copy link

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.

@techouse
Copy link

techouse commented Mar 20, 2022

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 😊

@devnoname120 devnoname120 linked a pull request Mar 23, 2022 that will close this issue
@devnoname120
Copy link

See #183

@xieao100
Copy link

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'

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants