简体   繁体   English

如何告诉 bash 使用 /usr/local/bin/python3 而不是 /usr/bin/python3?

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

I perl script that runs the following command:我运行以下命令的 perl 脚本:

/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.当 perl 脚本从命令行运行时,该脚本工作正常。 The command executes some python code in a library, tasklib , to insert a task into a TaskWarrior database.该命令执行库tasklib中的一些 python 代码,以将任务插入 TaskWarrior 数据库。

However, when the perl script is executed indirectly by an app, Karabiner Elements, I get errors.但是,当 perl 脚本由应用程序 Karabiner Elements 间接执行时,出现错误。

Some debug statements reveal this when the perl script is run standalone:当 perl 脚本独立运行时,一些调试语句会显示这一点:

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

However, when Karabiner executes the perl script, I see:但是,当 Karabiner 执行 perl 脚本时,我看到:

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

So an older 3.8 version of tasklib is getting used.因此,正在使用较旧的 3.8 版本的tasklib 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 .我需要以某种方式告诉 bash 使用 3.9.9 版本的 python 以便它可以在/usr/local/lib/python3.9/site-packages中找到更新的tasklib库。 How do I do this?我该怎么做呢?

Perhaps也许

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM