aberlee Posted August 5, 2020 Share Posted August 5, 2020 Hi! I have a workflow which uses a Script Filter that uses python It imports Tasklib module to access a program called Taskwarrior I've added : from workflow import Workflow import sys def main(wf): import tasklib # Imported from ./lib if __name__ == '__main__': wf = Workflow(libraries=['./lib']) sys.exit(wf.run(main)) from lib import tasklib I've installed using pip3 in the ./lib folder. I've tried adding: try: from functools import lru_cache except ImportError: from backports.functools_lru_cache import lru_cache Nothing changed. I tried adding the above to the backends.py in the tasklib module where it imports lru_cache from functools. Then a whole lot of other errors pop up. I'm thinking it's a python 2.7 vs. python 3 issue? Anyone else have any idea / suggestions what I can do? Thanks in advance! Link to comment
deanishe Posted August 5, 2020 Share Posted August 5, 2020 2 hours ago, aberlee said: I'm thinking it's a python 2.7 vs. python 3 issue? Almost certainly. You're using Python 2 and there is no functools.lru_cache in Python 2: the library you appear to be using doesn't support Python 2. Link to comment
aberlee Posted August 6, 2020 Author Share Posted August 6, 2020 (edited) Many thanks @deanishe. Well that seems to end my attempt to include this library then.. too bad.. unless.. Maybe a stupid follow-up. But is there a way to force Alfred to use python 3? Edited August 6, 2020 by aberlee Link to comment
deanishe Posted August 6, 2020 Share Posted August 6, 2020 (edited) 11 minutes ago, aberlee said: But is there a way to force Alfred to use python 3? No. It would break anything that expects Python 2, and it’s pointless anyway. Nobody uses “Language = /usr/bin/python” because putting code in the Script box is silly. Use External Script (or “Language = /bin/bash”) and an appropriate shebang (#!/usr/bin/python3) in your script. Edited August 6, 2020 by deanishe Link to comment
deanishe Posted August 6, 2020 Share Posted August 6, 2020 Be aware that Alfred-Workflow doesn't support Python 3 and will probably blow up in your face if you try to use it with Py3. aberlee 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now