Comments (11)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
See #183
from alfred-workflow.
Related Issues (20)
- Run with error HOT 2
- Cache Image HOT 5
- Basic auth HOT 3
- Pass parameter to subprocess HOT 5
- Tutorial options for keywords need to be updated for Alfred 4 HOT 11
- set_config raises error when the bundle id is null HOT 4
- Setting only arg on Variables adds line break HOT 1
- will it support python3? HOT 1
- python3 has no cpickle HOT 1
- cant get output HOT 11
- chr() arg not in range(256) error when trying to use Beautiful Soup 4 HOT 1
- workflow:magic not working?
- API functionality question
- AlertCautionIcon.icns does not exist on Big Sur
- ERROR: [Script Filter] JSON error
- Google SDK
- Can't get Script Filter to find the pinboard.py file from the tutorial HOT 1
- [Feature request] Possible to open bookmarks from root?
- How to fetch chrome cookie?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alfred-workflow.