14.3使用「阿里云函数计算 FC」时报错{“RequestId“:“1-69d72624-108afc-45d4bd4076b8“,“Code“:“CAExited“,“Message“:“Func

发布时间:2026/7/15 6:39:04
14.3使用「阿里云函数计算 FC」时报错{“RequestId“:“1-69d72624-108afc-45d4bd4076b8“,“Code“:“CAExited“,“Message“:“Func 报错{RequestId:1-69d72624-108afc-45d4bd4076b8,Code:CAExited,Message:Function instance exited unexpectedly(code 2, message:no such file or directory) with start command . \nLogs:python3: cant open file /code/index.py: [Errno 2] No such file or directory}报错核心原因启动命令和文件名不匹配这个报错的意思是函数计算找不到/code/index.py文件因为代码文件名叫app.py但启动命令还在找index.py第四步添加依赖文件requirements.txt回到函数详情页点击顶部标签栏的「配置」→ 「运行时配置」找到「启动命令」输入框如果是空的 → 填入python3 app.py如果是python3 index.py→ 修改成python3 app.py点击页面底部的「保存」按钮回到「代码」标签页全选删除app.py里的所有默认代码把下面的完整代码原封不动粘贴进去适配你的成都 Bucketourselvesfrom flask import Flask, Response import oss2 app Flask(__name__) # 替换成你自己的RAM子账号AK/SK OSS_ACCESS_KEY_ID 你的AccessKey ID OSS_ACCESS_KEY_SECRET 你的AccessKey Secret # # 成都地域OSS配置已适配你的Bucket名ourselves OSS_ENDPOINT osswe-cn-chengdu.aliyuncs.com OSS_BUCKET ourselves # 初始化OSS客户端 auth oss2.Auth(OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET) bucket oss2.Bucket(auth, OSS_ENDPOINT, OSS_BUCKET) # 处理we.html请求强制返回网页格式 app.route(/we.html) def get_html(): try: file_obj bucket.get_object(we.html) content file_obj.read() return Response(content, content_typetext/html; charsetutf-8) except Exception as e: return Response(fError: {str(e)}, status500) # 处理音频文件请求 app.route(/path:filename) def get_file(filename): try: file_obj bucket.get_object(filename) content_type file_obj.headers.get(Content-Type, application/octet-stream) return Response(file_obj.read(), content_typecontent_type) except Exception as e: return Response(404 Not Found, status404) if __name__ __main__: app.run(host0.0.0.0, port9000)把代码里的你的AccessKey ID和你的AccessKey Secret替换成你自己的 RAM 子账号密钥点击代码页的「保存」→「部署代码」橙色按钮等待 1 分钟部署完成在代码编辑区左侧右键点击hello_world文件夹 → 「新建文件」文件名填requirements.txt文件内容填flask oss2点击「保存」再点一次「部署代码」第五步重新访问链接部署完成后再次访问https://audio-miaomiaomiao-mpwulqeoed.cn-chengdu.fcapp.run/we.html即可