首页 > 解决方案 > Makefile 没有检测到 Python

问题描述

我的 Makefile 中有以下内容,

dosomething:
    ifeq (, $(shell which python))
        $(error "Python not installed, please download and install Python to create database")
    else
        cd myfolder; python myfile.py
    endif

当我运行时make dosomething,它会抛出错误,告诉我下载并安装 python。但是当我which python在我的外壳里做的时候,它说/usr/bin/python

不知道这里发生了什么

标签: shellmakefile

解决方案


我猜缩进的行以制表符开头?如果是这样,那么ifeq,elseendif指令将被视为命令的一部分并传递给 shell 执行。

为确保make评估这些指令,请删除前导选项卡...

dosomething:
ifeq (, $(shell which python))
        $(error "Python not installed, please download and install Python to create database")
else
        cd myfolder; python myfile.py
endif

推荐阅读