执行make命令提示未安装Python及编译工具缺失求助
问题排查:MAX78000FTHR示例编译报错(Python未检测到+arm-none-eabi-gcc缺失)
问题背景
运行从GitHub获取的MAX78000FTHR示例程序,队友已验证程序可正常编译,但执行make时遇到两个核心问题:
- 当前目录下
python/python3均可正常运行test1.py,但make提示No Python installation detected on your system! - 编译时报错
arm-none-eabi-gcc: Command not found
Make执行输出
annavladimirskaya@Annas-MacBook-Pro-6 mnist-riscv % vim test1.py annavladimirskaya@Annas-MacBook-Pro-6 mnist-riscv % python test1.py hello annavladimirskaya@Annas-MacBook-Pro-6 mnist-riscv % python3 test1.py hello annavladimirskaya@Annas-MacBook-Pro-6 mnist-riscv % make //Users/annavladimirskaya/Documents/mdsk/msdk/Libraries/CMSIS/Device/Maxim/GCC/gcc.mk:55: No Python installation detected on your system! Will not automatically update version info. **************************************************************************** * Analog Devices MSDK * v2024_02-149-gb9966ca6d8 * - User Guide: https://analogdevicesinc.github.io/msdk/USERGUIDE/ * - Get Support: https://www.analog.com/support/technical-support.html * - Report Issues: https://github.com/analogdevicesinc/msdk/issues * - Contributing: https://analogdevicesinc.github.io/msdk/CONTRIBUTING/ **************************************************************************** make[1]: arm-none-eabi-gcc: Command not found - CC //Users/annavladimirskaya/Documents/mdsk/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SYS/mxc_assert.c make[2]: arm-none-eabi-gcc: No such file or directory make[2]: *** [//Users/annavladimirskaya/Documents/mdsk/msdk/Libraries/PeriphDrivers/bin/MAX78000/spi-v1_softfp/mxc_assert.o] Error 1 make[1]: *** [//Users/annavladimirskaya/Documents/mdsk/msdk/Libraries/PeriphDrivers/bin/MAX78000/spi-v1_softfp/libPeriphDriver_spi-v1_softfp.a] Error 2 make: *** [arm] Error 2
相关Makefile代码片段
ifeq "$(PYTHON_CMD)" "" # Try python ifneq "$(wildcard $(MAXIM_PATH)/.github)" "" PYTHON_VERSION := $(shell python --version) ifneq ($(.SHELLSTATUS),0) PYTHON_CMD := none else PYTHON_CMD := python endif # Try python3 ifeq "$(PYTHON_CMD)" "none" PYTHON_VERSION := $(shell python3 --version) ifneq ($(.SHELLSTATUS),0) PYTHON_CMD := none else PYTHON_CMD := python endif endif # Export PYTHON_CMD so we don't check for it again unnecessarily export PYTHON_CMD endif # Make sure script exists before running. This won't run when working in the official MSDK release (non-GitHub) ifneq ("$(wildcard $(MAXIM_PATH)/.github)", "") # Run script if exists. ifneq "$(PYTHON_CMD)" "none" UPDATE_VERSION_OUTPUT := $(shell python $(MAXIM_PATH)/.github/workflows/scripts/update_version.py) else $(warning No Python installation detected on your system! Will not automatically update version info.) endif endif endif ifneq "$(wildcard $(MAXIM_PATH)/Libraries/CMSIS/Device/Maxim/GCC/mxc_version.mk)" "" include $(MAXIM_PATH)/Libraries/CMSIS/Device/Maxim/GCC/mxc_version.mk endif
问题分析与解决
1. Python检测失败的原因及解决
原因
从Makefile逻辑可以看出:
- 仅当
$(MAXIM_PATH)/.github存在(即GitHub克隆版本)时才会检测Python - 先尝试
python --version,失败后再尝试python3 --version - 关键问题:即使检测到
python3可用,仍将PYTHON_CMD设为python,最终执行更新脚本时用的是python命令 - Make的shell环境与交互式zsh环境不同,可能未继承你的alias或PATH配置,导致
python命令在make环境中无效
解决方法
- 临时解决:执行make时直接指定PYTHON_CMD为python3
make PYTHON_CMD=python3 - 半永久解决:当前shell环境导出PYTHON_CMD变量后再执行make
export PYTHON_CMD=python3 make - 永久解决:在zsh配置文件(
~/.zshrc)中添加alias python=python3,然后执行source ~/.zshrc,确保make的shell环境能识别python命令
2. arm-none-eabi-gcc找不到的原因及解决
原因
系统未安装ARM交叉编译工具链,或工具链路径未加入系统PATH环境变量,导致make无法找到arm-none-eabi-gcc命令
解决方法
- 安装工具链:通过Homebrew安装(推荐)
或从ARM官网下载对应Mac版本的工具链,手动解压到本地目录brew install arm-none-eabi-gcc - 验证安装:执行
arm-none-eabi-gcc --version,能输出版本信息则安装成功 - 添加到PATH:
- Homebrew安装的工具链通常在
/usr/local/bin(Intel Mac)或/opt/homebrew/bin(M系列Mac),确保该路径在你的PATH中 - 手动安装的话,比如解压到
~/arm-toolchain,在~/.zshrc中添加:export PATH="$PATH:~/arm-toolchain/bin" - 执行
source ~/.zshrc使配置生效后,再运行make
- Homebrew安装的工具链通常在
内容的提问来源于stack exchange,提问作者Anna V
相关产品推荐
相关产品推荐

