执行XED构建脚本mfile.py遇python3找不到错误及Git Bash异常求助
Intel XED构建时
./mfile.py执行报错的解决方法 问题描述
我按照Intel XED的GitHub精简构建说明操作:
git clone https://github.com/intelxed/xed.git xed git clone https://github.com/intelxed/mbuild.git mbuild cd xed ./mfile.py
前三条命令执行正常,但运行最后一条命令时出现如下错误:
$ ./mfile.py /usr/bin/env: ‘python3’: No such file or directory
已将Python 3.11安装到c:\python目录,尝试过相关解决方案但无效。补充说明:在Git Bash中进入mfile.py所在目录执行./mfile.py时,是Git Bash直接执行该文件,而非Python解释器。
解决方法
直接指定Python解释器运行脚本
跳过./mfile.py的调用方式,直接用已安装的Python执行脚本:# 如果Git Bash中`python`命令指向Python3 python mfile.py # 或者用完整路径指定Python3.11 c:/python/python.exe mfile.py给Python3创建Git Bash可识别的软链接
在Git Bash中执行以下命令,把Windows下的Python3.11链接到Git Bash的/usr/bin目录下,命名为python3:ln -s /c/python/python.exe /usr/bin/python3创建完成后,再运行
./mfile.py即可正常调用Python3解释器。修改脚本的Shebang行
打开mfile.py文件,将第一行的#!/usr/bin/env python3修改为Windows下Python的完整路径,或者适配Git Bash的Python命令:# 改成指定Python3.11的路径 #!/c/python/python.exe # 或者如果Git Bash中`python`指向Python3,可改成 #!/usr/bin/env python修改后保存文件,再次执行
./mfile.py即可正常运行。
内容的提问来源于stack exchange,提问作者JkT
相关产品推荐
相关产品推荐

