amplify mock function fails on awsgi not found

13 Views Asked by At

I am working to get a better understanding of Python on AWS by following this tutorial.

I seem to be having a problem with my Python environment. When I run

$ amplify mock function britneyspearsapi

I receive the following output:

(britney-spears-api-TX1XXQvB) ➜  britneyspearsapi git:(main) ✗ amplify mock function britneyspearsapi
✔ Provide the path to the event JSON object relative to /Users/<user_folder>/Workspace/britney-spears-api/amplify/backend/function/britneyspearsapi · src/event.json
Ensuring latest function changes are built...
Starting execution...
Traceback (most recent call last):
  File "/Users/<user_folder>/.amplify/lib/amplify-python-function-runtime-provider/shim/shim.py", line 44, in <module>
    main(sys.argv[1:])
  File "/Users/<user_folder>/.amplify/lib/amplify-python-function-runtime-provider/shim/shim.py", line 22, in main
    spec.loader.exec_module(handlerModule)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/<user_folder>/Workspace/britney-spears-api/amplify/backend/function/britneyspearsapi/src/index.py", line 1, in <module>
    import awsgi
ModuleNotFoundError: No module named 'awsgi'
 britneyspearsapi failed with the following error:
Command failed with exit code 1: pipenv run python3 /Users/<user_folder>/.amplify/lib/amplify-python-function-runtime-provider/shim/shim.py /Users/<user_folder>/Workspace/britney-spears-api/amplify/backend/function/britneyspearsapi/src/index.py handler
Traceback (most recent call last):
  File "/Users/<user_folder>/.amplify/lib/amplify-python-function-runtime-provider/shim/shim.py", line 44, in <module>
    main(sys.argv[1:])
  File "/Users/<user_folder>/.amplify/lib/amplify-python-function-runtime-provider/shim/shim.py", line 22, in main
    spec.loader.exec_module(handlerModule)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/<user_folder>/Workspace/britney-spears-api/amplify/backend/function/britneyspearsapi/src/index.py", line 1, in <module>
    import awsgi
ModuleNotFoundError: No module named 'awsgi'
Finished execution.

This is the output of my pip freeze and which python commands:

(britney-spears-api-TX1XXQvB) ➜  britneyspearsapi git:(main) ✗ pip freeze
    aws-wsgi==0.2.7
    awsgi==0.0.5
    blinker==1.7.0
    boto3==1.34.69
    botocore==1.34.69
    click==8.1.7
    Flask==3.0.2
    Flask-Cors==4.0.0
    httptools==0.6.1
    importlib_metadata==7.1.0
    itsdangerous==2.1.2
    Jinja2==3.1.3
    jmespath==1.0.1
    MarkupSafe==2.1.5
    python-dateutil==2.9.0.post0
    s3transfer==0.10.1
    six==1.16.0
    urllib3==1.26.18
    uvloop==0.19.0
    websockets==12.0
    Werkzeug==3.0.1
    zipp==3.18.1
(britney-spears-api-TX1XXQvB) ➜  britneyspearsapi git:(main) ✗ which python
    /Users/<user_folder>/.virtualenvs/britney-spears-api-TX1XXQvB/bin/python

I'm not as familiar with troubleshooting missing packages on Amplify. What should I try next?

0

There are 0 best solutions below