我正在尝试在Mac OS X Mojave上创建一个Automator应用程序,以启动pyenv。
如果我从bash shell运行此命令,它将正常工作:
@api_view(["POST"])
def FoodResponse(request):
try:
#defining variables
calMoy=500
percentage=0.1
calSum=0
# Lookup the food objects up using the primary key
starter = Food.objects.get(pk=request.POST['starter'])
dish = Food.objects.get(pk=request.POST['dish'])
desert = Food.objects.get(pk=request.POST['desert'])
# Retrieve the calories and calculate the total
calSum= calSum + starter.cal+ dish.cal + desert.cal
...
但是在Automator中,出现以下错误:
pyenv activate myenv
如果我在外壳程序脚本的开头添加The action “Run Shell Script” encountered an error: “[31;1m
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
[0m”
[31;1m
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
[0m
,则表明Automator正在以我的身份运行脚本,因此它应具有相同的whoami
等。但是,如果我回显{ {1}}变量显然与我直接从外壳程序运行它不同。在脚本中手动设置$PATH
也无济于事。
奇怪的是,在脚本中运行$PATH
不会生成任何输出。
运行$PATH
会生成输出:python --version
关于这为什么不起作用的任何线索?