Jump to content

Making Python 2 Workflows work on macOS Monterey 12.3 and above


Recommended Posts

1 hour ago, timhilde said:

 

Somehow this isn't working on my end. I've reinstalled Python 2 with this guide and downloaded the updated workflow, but still nothing... 

 

That's because most older scripts address hardcoded to `/usr/bin/python`, while the guide pointing out the homebrew bin location `/opt/homebrew/bin/python`.

 

As work around you can try to link it somehow but that didn't worked for me and I got error:

> sudo ln -s /opt/homebrew/bin/python /usr/bin/python
ln: /usr/bin/python: Operation not permitted

 

Alternative you could do as workaround a hard search and replace with an editor like VisualCode or Sublime trough the whole workflow folder and replace the hardcoded lines `/usr/bin/python` to  `/opt/homebrew/bin/python`. But before doing something like this, you should make a backup of this folder or even your whole Alfred preferences first.

 

Just so you can recover everything when better guides or workarounds getting released.

 

I don't know for sure (not a python developer), but I bet modern workflow-scripts doesn't use hardcoded-locations anymore and detecting instead the  binary-locations from the PATH varialbe we setuped before.

Edited by _Sascha_
Link to comment
19 hours ago, vitor said:

 

Added.

 

 

Editing the list isn’t very useful, because your changes won’t propagate to other people and they may not have whatever runtime you’ve added. It could cause hard-to-diagnose problems when sharing Workflows.

 

 

Save your script inside the Workflow with a proper shebang (#!/usr/bin/python3) and call it as an External Script as the Language. Or use /bin/zsh as the Language and call your script with /usr/bin/python3 SCRIPT_NAME. You were never limited by the languages in the dropdown, you can easily use anything on your system.

 

Updated video conference shows all upcoming meetings, launch safari but clicking open teams apps doesn't work. I think earlier it used to launch teams directly. Request for re-check on it.

Link to comment
16 hours ago, _Sascha_ said:

That's because most older scripts address hardcoded to `/usr/bin/python`, while the guide pointing out the homebrew bin location `/opt/homebrew/bin/python`.

 

That is not correct. You have to follow the whole guide and you’ll end up with Python in the correct location—which depends on your CPU architecture—to be used by these updated Workflows.

 

16 hours ago, _Sascha_ said:

As work around you can try to link it somehow but that didn't worked for me and I got error:

 

No, don’t do that! There is a reason macOS stops you and the guide doesn’t suggest it: so you don’t shoot yourself in the foot. Even if you got it to work by forcing it, you’d be introducing things in a way macOS doesn’t expect and could mess up unrelated apps on your system.

 

16 hours ago, _Sascha_ said:

Alternative you could do as workaround a hard search and replace with an editor like VisualCode or Sublime trough the whole workflow folder and replace the hardcoded lines `/usr/bin/python` to  `/opt/homebrew/bin/python`.

 

That won’t work either. You’re only considering Python installations via Homebrew on Apple Silicon, which ignores a huge percentage of users. Plus, it wouldn’t fix cases where the whole path isn’t included.

 

16 hours ago, _Sascha_ said:

Just so you can recover everything when better guides or workarounds getting released.

 

The current guide and workaround are good. This was not a rush job, it has been in place and working for weeks. It was thought out and tested to be the most efficient and simple way to provide a working installation for most people.

 

16 hours ago, _Sascha_ said:

I don't know for sure (not a python developer), but I bet modern workflow-scripts doesn't use hardcoded-locations anymore and detecting instead the  binary-locations from the PATH varialbe we setuped before.

 

That is also incorrect. It’s fine that you don’t know these things, we all have to learn, but please don’t confuse users. If you don’t know, it’s harmful to others to contradict the official instructions. Those have been studied, tested, and improved from a thorough understanding of the problem.

Edited by vitor
Link to comment
20 hours ago, pankajsz said:

https://github.com/deanishe/alfred-appscripts. - pls post an update for this. General guidelines on how to fix Python2 issue would be great. thanks in advance

 

That one is already there. You have to check the GitHub repository for the full list. It also includes links to general guidelines on the fixes.

 

18 hours ago, timhilde said:

Somehow this isn't working on my end.

 

Welcome. Please redownload it (same URL) and try again, as I just did further tweaks.

 

14 hours ago, xilopaint said:

I really think the community should put some effort to update our workflows and add support to Python3.

 

I agree. But that takes time. And we also have to think of the non-coders who find themselves with broken tools and need a workaround. This solution is a stop-gap, not the end goal. See my other comment for a more complete answer.

 

7 hours ago, Ehler said:

Could Alfred Bear be added?

 

Added.

 

5 hours ago, pankajsz said:

Updated video conference shows all upcoming meetings, launch safari but clicking open teams apps doesn't work.

 

That’s not a Python problem. Maybe you need to update the regex in the Workflow Environment Variable or do another thing. As per the top post: “this is only for Python 2 Workflows which break on Monterey 12.3 and above due to the Python 2 removal. If a Workflow stops working for any other reason, contact the author as usual”.

 

5 hours ago, kithairon said:

any chance that the workflow Favorites (Tyler Eich) could be added to this list?

 

Added.

Edited by vitor
Link to comment
1 hour ago, vitor said:
15 hours ago, xilopaint said:

I really think the community should put some effort to update our workflows and add support to Python3.

 

I agree. But that takes time. And we also have to think of the non-coders who find themselves with broken tools and need a workaround. This solution is a stop-gap, not the end goal. See my other comment for a more complete answer.

 

I've always been curious about the percentage of non-coders in Alfred's Powerpack user base.

Edited by xilopaint
Link to comment
4 hours ago, xilopaint said:

 

I've always been curious about the percentage of non-coders in Alfred's Powerpack user base.

 

I'm a music teacher. I've tried to learning Javascript (for apps like Drafts and Omni Automation) before but I haven't really been successful. My interest in learning Python would only be to write my own Alfred workflows, but others are doing a good enough job that the fact I'll probably never find the time doesn't bother me. Alfred speeds up my work more than anything else, and while I'd love to be able to take that further, I probably won't ever be in a position to.

Link to comment
1 minute ago, vitor said:

@evanfuchs That one is being handled by the original author and has already been rewritten, as you’ve seen in the original thread.

 

Please don’t ask for ports of such Workflows, the original author should always be the first contact. Official fixes are preferred.

Okay.

 

FYI, this was not clear to me in the OP: "Check the list of available Workflows. If the one you need isn’t present, ask for it there or as a reply on this thread. Be sure to include a link to the original."

Link to comment
11 minutes ago, evanfuchs said:

this was not clear to me in the OP


Fair. But checking for updates with the original developer is covered in both the GitHub repo and the instructions for reinstalling Python 2, both of which are required reading linked from this thread. Doesn’t seem worth it to repeat it yet again, but I’ll give it a thought.

Link to comment
On 3/15/2022 at 7:32 PM, pankajsz said:

General guidelines on how to fix Python2 issue would be great.

 

Just google any porting guide. Python 3 has been around since 2008 (though I’d argue it wasn’t usable till a decade later…), so there’s plenty of material available. In most cases, you might need to change a couple of import statements, but the majority of the work will be rewriting the string processing. Seeing as this is the meat-and-potatoes of what most workflows do, many ports will end up closer to rewrites.

Link to comment

Hi.

I'm not a developer. I created the workflow of the desired function by referring to various materials on the Internet. However, it will not work after the update, so I would like to ask for your help. Is it possible?
I don't have a GitHub account because I'm not a developer. Can I upload the download link directly?

 

naverSuggest.alfredworkflow

https://d.pr/f/To5a1X

 

naverCafeSearch.alfredworkflow

https://d.pr/f/B5Nc6K

Edited by idhun90
Link to comment

convert also not working

 

```

[11:56:32.299] Logging Started...
[11:56:36.563] Convert[Script Filter] Queuing argument '100us'
[11:56:36.824] Convert[Script Filter] Script with argv '100us' finished
[11:56:36.825] ERROR: Convert[Script Filter] Code 1: .
http_proxy=
https_proxy=
Traceback (most recent call last):
  File "/Users/mich/Dropbox/AlfredSync/Alfred.alfredpreferences/workflows/user.workflow.D8C54D20-2ABC-4EA7-8265-0D614AC27080/convert.py", line 20, in <module>
    from workflow import Workflow3, ICON_WARNING, ICON_INFO
  File "/Users/mich/Dropbox/AlfredSync/Alfred.alfredpreferences/workflows/user.workflow.D8C54D20-2ABC-4EA7-8265-0D614AC27080/workflow/__init__.py", line 16, in <module>
    from .workflow import Workflow, manager
  File "/Users/mich/Dropbox/AlfredSync/Alfred.alfredpreferences/workflows/user.workflow.D8C54D20-2ABC-4EA7-8265-0D614AC27080/workflow/workflow.py", line 25, in <module>
    import cPickle
ModuleNotFoundError: No module named 'cPickle'

```

 

Link to comment

@michbsd Please don’t post in multiple places. That makes the conversation more difficult for everyone, including people coming after.

 

@Smpl Technically it’s not using Homebrew, it’s using pyenv. But the reason is the same: installations are self-contained and don’t affect anything else on your system. If you ever decide you no longer want Python 2, you delete ~/.pyenv and the symlink and you’re good to go. In contrast, the download provided on Python’s website is a PKG installer which can do anything and will leave you with receipts. Plus, they don’t provide a v2 installer for Apple Silicon.

Link to comment

Hi, I currently use only Python 3.10 and usually use venv to setup my environments. I can move over to pyenv to install my python versions, but I still have the issue whereby I must switch python versions each time I need to use a workflow. Is there a way to get Alfred to change the path when workflows are run so I can keep my preferred Python toolset in my shell and editor? 

 

 

Edited by iandol
Link to comment
19 minutes ago, iandol said:

...but I still have the issue whereby I must switch python versions each time I need to use a workflow.

 

 

 

To partially answer my own question pyenv does support multiple python versions and 'cascades' the versions making symlinks for specific versions: https://github.com/danhper/asdf-python#using-multiple-versions-of-python — so I could manually use python2.7 symlink for the workflows?

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