Search code examples
pythonbashkarabinertaskwarrior

How do I tell bash to use /usr/local/bin/python3 instead of /usr/bin/python3?


I perl script that runs the following command:

/bin/bash -c 'TASKRC=/Users/me/.taskrc /usr/local/bin/task add \'the task\''

The script works fine when the perl script is run from the command line. The command executes some python code in a library, tasklib, to insert a task into a TaskWarrior database.

However, when the perl script is executed indirectly by an app, Karabiner Elements, I get errors.

Some debug statements reveal this when the perl script is run standalone:

Python version: 3.9.9
Python bin: /usr/local/bin/python3

However, when Karabiner executes the perl script, I see:

Python version: 3.8.9
Python bin: /usr/bin/python3

So an older 3.8 version of tasklib is getting used. I need to somehow to tell bash to use the 3.9.9 version of python so it can find the newer tasklib library found in /usr/local/lib/python3.9/site-packages. How do I do this?


Solution

  • Perhaps

    /bin/bash -c 'PATH=/usr/local/bin:$PATH; TASKRC=/Users/me/.taskrc task add "the task"'