英文:
No module named 'pydantic_core._pydantic_core' in AWS Lambda though library is installed for fast api based code
问题
AWS Lambda 部署 FastAPI 时出现以下错误:
[ERROR] Runtime.ImportModuleError: 无法导入模块 'users_crud':没有找到模块 'pydantic_core._pydantic_core'
Traceback(最近的调用最后):
尽管已安装 pydantic 库。我正在使用 AWS 支持的版本 3.10。
英文:
AWS lambda deployment of FastAPI gives the following error:
[ERROR] Runtime.ImportModuleError: Unable to import module 'users_crud': No module named 'pydantic_core._pydantic_core'
Traceback (most recent call last):
Though the pydantic lib is already installed. I am using version 3.10 which is now supported by AWS.
答案1
得分: 5
我今早遇到了相同的错误。
我查看了FastAPI的发布说明:新版本0.100.0在Pydantic方面有一些变化。我不是很理解其中的所有内容,但对于我的问题,一个快速临时的解决方法是将FastAPI版本锁定为0.99.0。
希望对你也有帮助。
英文:
I had the same error this morning.
I checked the release notes of FastAPI: new release 0.100.0 has some changes wrt Pydantic. I don't understand all of them, but a quick & temporary workaround to my problem is to version pin FastAPI==0.99.0.
Hope that helps for you as well.
答案2
得分: 1
请查看pydantic/pydantic#6557 - 基本上您可能错误地安装了错误架构的pydantic-core
。
英文:
Please see pydantic/pydantic#6557 - basically you've probably installed pydantic-core
for the wrong architecture.
答案3
得分: 0
在我的情况下,解决这个问题的方法是在Linux系统上运行pip install
(它可以自动安装正确版本)。我在lambda层上使用了pydantic而没有使用fastapi,并使用了py39
x86
架构创建了库。另外,如果你无法访问Linux环境,直接解压缩'whl'文件也可能会有所帮助。
英文:
In my case, the solution to this problem was running pip install
on a Linux system(it can auto install correct version).
I used pydantic without fastapi and created libraries at a lambda layer with py39
x86
architecture.
Additionally, if you are unable to access a Linux environment, directly unzipping the 'whl' file might also be helpful.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论