I'm working in a project develop with serverless framework, Flask and MongoDB. The problem it's when I try to install pydantic, in the traceback say's ModuleNotFoundError: No module named 'pydantic_core._pydantic_core' but in my requirements is specify the library.
Is there a form to install pydantic or is not possible install the library in Lambda's AWS?
Traceback in Cloudwatch
File "/var/task/app.py", line 5, in <module>from pydantic import ValidationErrorFile "/var/task/pydantic/__init__.py", line 3, in <module>import pydantic_coreFile "/var/task/pydantic_core/__init__.py", line 6, in <module>from ._pydantic_core import (ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'[ERROR] Exception: Unable to import app.appTraceback (most recent call last): File "/var/lang/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 690, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/var/task/wsgi_handler.py", line 115, in <module> wsgi_app = import_app(config) File "/var/task/wsgi_handler.py", line 48, in import_app raise Exception("Unable to import {}".format(config["app"]))
I've tried downgrading the version of python, pydantic, Flask. I also specified the library pydantic_core and not working.
requirements.txt
Flask==1.1.4Werkzeug==1.0.1markupsafe==2.0.1pymongo==4.5.0pydantic==2.2.1pydantic_core==2.6.1email-validator==2.0.0.post2
serverless.yml
service: usersframeworkVersion: "3"custom: wsgi: app: app.appprovider: name: aws runtime: python3.11 stage: dev region: us-west-2 environment: MONGO_URI: <mongo_uri>functions: api: handler: wsgi_handler.handler events: - httpApi: "*"plugins: - serverless-wsgi - serverless-python-requirements