Coder Social home page Coder Social logo

Comments (11)

moneygalaxy avatar moneygalaxy commented on June 3, 2024 16

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"

from alfred-workflow.

psifertex avatar psifertex commented on June 3, 2024 6

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)

from alfred-workflow.

raingao avatar raingao commented on June 3, 2024 3

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

from alfred-workflow.

techouse avatar techouse commented on June 3, 2024 2

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 😊

from alfred-workflow.

xieao100 avatar xieao100 commented on June 3, 2024 2

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'

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

from alfred-workflow.

fedecalendino avatar fedecalendino commented on June 3, 2024

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.

from alfred-workflow.

psifertex avatar psifertex commented on June 3, 2024

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

from alfred-workflow.

xavdid avatar xavdid commented on June 3, 2024

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

from alfred-workflow.

FischLu avatar FischLu commented on June 3, 2024

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.

from alfred-workflow.

fedecalendino avatar fedecalendino commented on June 3, 2024

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.

from alfred-workflow.

devnoname120 avatar devnoname120 commented on June 3, 2024

See #183

from alfred-workflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.