Jump to content

ImportError: cannot import name lru_cache and cannot seem to solve it

Recommended Posts



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'])

from lib import tasklib

I've installed using pip3 in the ./lib folder. 


I've tried adding: 

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