小编Bel*_*len的帖子

firebase云函数内的模块与python:ModuleNotFoundError:没有名为“src”的模块

我有一个这样的目录结构:

python-functions/
--src
---- | api/
-------- | __init__.py
-------- | main.py
---- | __init__.py
---- | main.py
Run Code Online (Sandbox Code Playgroud)

我试图在 src/main.py 中定义所有函数,但在其相应的文件夹中有实现

python-functions/
--src
---- | api/
-------- | __init__.py
-------- | main.py
---- | __init__.py
---- | main.py
Run Code Online (Sandbox Code Playgroud)
# src/main.py
import src.api.main as api

@https_fn.on_request(timeout_sec=300)
def status(req: https_fn.Request) -> https_fn.Response:
    return api.status(req)
Run Code Online (Sandbox Code Playgroud)

但是在部署时我收到此错误:

# Importing like: import src
ModuleNotFoundError: No module named 'src'
127.0.0.1 - - [18/May/2023 00:09:43] "GET /\_\_/functions.yaml HTTP/1.1" 500 -
Error: Failed to parse build specification:

- …
Run Code Online (Sandbox Code Playgroud)

python firebase google-cloud-platform firebase-tools google-cloud-functions

1
推荐指数
1
解决办法
828
查看次数