Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pycharm lambda debug on docker container fail with SyntaxError: Non-UTF-8 code starting with '\x96' in file /var/lang/bin/python3.9 #3609

Closed
Yahel-B opened this issue Apr 18, 2023 · 6 comments
Labels
guidance General information and guidance, answers to FAQs, or recommended best practices/resources.

Comments

@Yahel-B
Copy link

Yahel-B commented Apr 18, 2023

Hey there!
I'm trying to debug an aws lambda which runs on a docker container using pycharm and aws toolkit. for some reason, only when trying to DEBUG I get this error (on Run everything works well):

SyntaxError: Non-UTF-8 code starting with '\x96' in file /var/lang/bin/python3.9 on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
time="2023-03-22T12:28:18.304" level=error msg="Init failed" InvokeID= error="Runtime exited with error: exit status 1"

I've tried adding to my docker file these lines which didn't help:
RUN yum install glibc-all-langpacks
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

I've also tried adding to my app.py file which didn't help:

#!/usr/bin/python
# -*- coding: utf-8 -*-

I tried to contact Pycharm support but they told me that since it's a 3rd party plugin I need to contact AWS for help.

template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description:

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 30
    MemorySize: 128

Resources:
  SingleStoreFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      PackageType: Image
      ImageConfig:
          Command: [ "app.lambda_handler" ]
      Handler: app.lambda_handler
      Runtime: python3.9
    Metadata:
      Dockerfile: Dockerfile
      DockerContext: ../../
      DockerTag: v1

dockerfile:

FROM public.ecr.aws/lambda/python:3.9

COPY single_store/single_store_gamestate ./
COPY lambda_utils/src ./

RUN python3.9 -m pip install -r requirements.txt

CMD ["app.lambda_handler"]

output:

{\rtf1\ansi\ansicpg1252\cocoartf2639
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0

\f0\fs24 \cf0 docker ps\
/usr/local/Cellar/aws-sam-cli/1.35.0/libexec/bin/sam build SingleStoreFunction --template /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate/template.yaml --build-dir /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate/.aws-sam/build --use-container\
Starting Build inside a container\
Building codeuri: /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate runtime: python3.9 metadata: \{'Dockerfile': 'Dockerfile', 'DockerContext': '/Users/yahel/SlateApps/aws/lambda', 'DockerTag': 'v1'\} architecture: x86_64 functions: ['SingleStoreFunction']\
Building image for SingleStoreFunction function\
Setting DockerBuildArgs: \{\} for SingleStoreFunction function\
Step 1/5 : FROM public.ecr.aws/lambda/python:3.9\
\
3.9: Pulling from lambda/python \
2a2cc0d36b60: Already exists \
e09d761c851a: Already exists \
0a7d5b36cadf: Already exists \
072730bdc14d: Already exists \
b546b14c8cf0: Already exists \
e046c1efb9ee: Already exists \
Digest: sha256:bfed82c0e9b023563877172d15432b7601bbfd80d50a47c08acc0a354fff3064\
Status: Downloaded newer image for public.ecr.aws/lambda/python:3.9 ---> 2f2f3fd16013\
Step 2/5 : COPY single_store/single_store_gamestate ./\
 ---> 637b0271e7d5\
Step 3/5 : COPY lambda_utils/src ./\
 ---> 30c983df9b7f\
Step 4/5 : RUN pip install -r requirements.txt\
 ---> Running in 754ce9f74ab6\
Collecting requests\
  Downloading requests-2.28.2-py3-none-any.whl (62 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  62.8/62.8 KB 977.0 kB/s eta 0:00:00\
Collecting singlestoredb\
  Downloading singlestoredb-0.5.4-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (214 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  214.2/214.2 KB 2.8 MB/s eta 0:00:00\
Collecting redis\
  Downloading redis-4.5.3-py3-none-any.whl (238 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  238.6/238.6 KB 10.4 MB/s eta 0:00:00\
Collecting kafka-python\
  Downloading kafka_python-2.0.2-py2.py3-none-any.whl (246 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  246.5/246.5 KB 15.4 MB/s eta 0:00:00\
Collecting certifi>=2017.4.17\
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  155.3/155.3 KB 15.0 MB/s eta 0:00:00\
Collecting urllib3<1.27,>=1.21.1\
  Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  140.9/140.9 KB 13.4 MB/s eta 0:00:00\
Collecting charset-normalizer<4,>=2\
  Downloading charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  199.2/199.2 KB 17.5 MB/s eta 0:00:00\
Collecting idna<4,>=2.5\
  Downloading idna-3.4-py3-none-any.whl (61 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  61.5/61.5 KB 7.6 MB/s eta 0:00:00\
Collecting PyJWT\
  Downloading PyJWT-2.6.0-py3-none-any.whl (20 kB)\
Collecting wheel\
  Downloading wheel-0.40.0-py3-none-any.whl (64 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  64.5/64.5 KB 7.4 MB/s eta 0:00:00\
Collecting sqlparams\
  Downloading sqlparams-5.1.0-py3-none-any.whl (16 kB)\
Collecting build\
  Downloading build-0.10.0-py3-none-any.whl (17 kB)\
Collecting async-timeout>=4.0.2\
  Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)\
Collecting packaging>=19.0\
  Downloading packaging-23.0-py3-none-any.whl (42 kB)\
     \uc0\u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473 \u9473  42.7/42.7 KB 5.9 MB/s eta 0:00:00\
Collecting tomli>=1.1.0\
  Downloading tomli-2.0.1-py3-none-any.whl (12 kB)\
Collecting pyproject_hooks\
  Downloading pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)\
Installing collected packages: kafka-python, wheel, urllib3, tomli, sqlparams, PyJWT, packaging, idna, charset-normalizer, certifi, async-timeout, requests, redis, pyproject_hooks, build, singlestoredb\
Successfully installed PyJWT-2.6.0 async-timeout-4.0.2 build-0.10.0 certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 kafka-python-2.0.2 packaging-23.0 pyproject_hooks-1.0.0 redis-4.5.3 requests-2.28.2 singlestoredb-0.5.4 sqlparams-5.1.0 tomli-2.0.1 urllib3-1.26.15 wheel-0.40.0\
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.\
You should consider upgrading via the '/var/lang/bin/python3.9 -m pip install --upgrade pip' command.\
 ---> 4a899df6d773\
Step 5/5 : CMD ["app.lambda_handler"]\
 ---> Running in fef03acff0b9\
 ---> 55a448c9e6d8\
Successfully built 55a448c9e6d8\
Successfully tagged singlestorefunction:v1\
\
\
Build Succeeded\
\
Built Artifacts  : .aws-sam/build\
Built Template   : .aws-sam/build/template.yaml\
\
Commands you can use next\
=========================\
[*] Invoke Function: sam local invoke\
[*] Deploy: sam deploy --guided\
        \
/usr/local/Cellar/aws-sam-cli/1.35.0/libexec/bin/sam local invoke SingleStoreFunction --template /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate/.aws-sam/build/template.yaml --event "/private/var/folders/94/tfyd42c12v35p2q2yrl3r9n80000gn/T/[Local] SingleStoreFunction-event836.json" --debugger-path /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev --debug-args "/var/lang/bin/python3.9 -u /tmp/lambci_debug_files/pydevd.py --multiprocess --port 53126 --file /var/runtime/bootstrap.py" --debug-port 53126\
Invoking Container created from singlestorefunction:v1\
Image was not found.\
Removing rapid images for repo singlestorefunction\
Building image.................\
Skip pulling image and use local one: singlestorefunction:rapid-1.35.0-x86_64.\
\
START RequestId: f47eecbc-137c-4c18-a709-819fdff5108a Version: $LATEST\
SyntaxError: Non-UTF-8 code starting with '\\x96' in file /var/lang/bin/python3.9 on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details\
time="2023-03-26T09:03:26.081" level=error msg="Init failed" InvokeID= error="Runtime exited with error: exit status 1"\
SyntaxError: Non-UTF-8 code starting with '\\x96' in file /var/lang/bin/python3.9 on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details\
END RequestId: 113fd73c-f541-4690-a0e7-29ec3e6784d7\
REPORT RequestId: 113fd73c-f541-4690-a0e7-29ec3e6784d7	Init Duration: 0.82 ms	Duration: 55.84 ms	Billed Duration: 56 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	\
}

image
image
image

Environment

  • OS: mac os
  • JetBrains product: pycharm
  • JetBrains product version: 2022.2.5
  • AWS Toolkit version: 1.60-222
  • SAM CLI version:1.35.0
  • Python version: 3.9
@Yahel-B Yahel-B added the bug We can reproduce the issue and confirmed it is a bug. label Apr 18, 2023
@rli
Copy link
Contributor

rli commented Apr 18, 2023

Can you confirm that your source files are using the UTF-8 encoding?
https://www.jetbrains.com/help/idea/encoding.html

@rli rli added needs-response Waiting on additional info and feedback from GitHub community. (no auto closure) guidance General information and guidance, answers to FAQs, or recommended best practices/resources. and removed bug We can reproduce the issue and confirmed it is a bug. labels Apr 18, 2023
@Yahel-B
Copy link
Author

Yahel-B commented Apr 19, 2023

@rli Yes, all my source files are utf-8.
I also updated aws-sam-cli to the newest version. Unfortunately the error still occurs
this is the output after the aws-sam-cli update:

docker ps
/usr/local/bin/sam build SingleStoreFunction --template /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate/template.yaml --build-dir /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate/.aws-sam/build --use-container
Starting Build inside a container
Building codeuri: /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate runtime: python3.9 metadata: {'Dockerfile': 'Dockerfile', 'DockerContext': '/Users/yahel/SlateApps/aws/lambda', 'DockerTag': 'v1'} architecture: x86_64 functions: SingleStoreFunction
Building image for SingleStoreFunction function
Setting DockerBuildArgs: {} for SingleStoreFunction function
Step 1/5 : FROM public.ecr.aws/lambda/python:3.9

3.9: Pulling from lambda/python
069d51b0476d: Pulling fs layer
ee7094de4c48: Pulling fs layer
200b63deca0b: Pulling fs layer
072730bdc14d: Pulling fs layer
97466eb1c2ad: Pulling fs layer
103930488ac4: Pulling fs layer
072730bdc14d: Waiting
97466eb1c2ad: Waiting
103930488ac4: Waiting
200b63deca0b: Downloading [==================================================>]     417B/417B
200b63deca0b: Verifying Checksum
200b63deca0b: Download complete
ee7094de4c48: Downloading [=========>                                         ]  16.38kB/85.88kB
ee7094de4c48: Downloading [==================================================>]  85.88kB/85.88kB
ee7094de4c48: Verifying Checksum
ee7094de4c48: Download complete
069d51b0476d: Downloading [>                                                  ]  531.9kB/104.8MB
069d51b0476d: Downloading [==>                                                ]  5.858MB/104.8MB
069d51b0476d: Downloading [=====>                                             ]   11.7MB/104.8MB
069d51b0476d: Downloading [========>                                          ]  17.01MB/104.8MB
069d51b0476d: Downloading [===========>                                       ]  23.39MB/104.8MB
069d51b0476d: Downloading [=============>                                     ]  28.16MB/104.8MB
069d51b0476d: Downloading [===============>                                   ]  33.47MB/104.8MB
072730bdc14d: Downloading [>                                                  ]  32.77kB/2.405MB
069d51b0476d: Downloading [==================>                                ]  38.27MB/104.8MB
072730bdc14d: Downloading [==============================>                    ]  1.456MB/2.405MB
97466eb1c2ad: Downloading [>                                                  ]  536.4kB/60.48MB
072730bdc14d: Download complete
069d51b0476d: Downloading [====================>                              ]  43.02MB/104.8MB
97466eb1c2ad: Downloading [===>                                               ]  3.718MB/60.48MB
069d51b0476d: Downloading [======================>                            ]  47.79MB/104.8MB
97466eb1c2ad: Downloading [======>                                            ]  7.486MB/60.48MB
069d51b0476d: Downloading [========================>                          ]  52.03MB/104.8MB
97466eb1c2ad: Downloading [========>                                          ]  10.68MB/60.48MB
069d51b0476d: Downloading [==========================>                        ]  55.74MB/104.8MB
97466eb1c2ad: Downloading [===========>                                       ]  14.46MB/60.48MB
069d51b0476d: Downloading [============================>                      ]  58.92MB/104.8MB
97466eb1c2ad: Downloading [===============>                                   ]   18.2MB/60.48MB
069d51b0476d: Downloading [==============================>                    ]  63.17MB/104.8MB
97466eb1c2ad: Downloading [=================>                                 ]  21.38MB/60.48MB
069d51b0476d: Downloading [===============================>                   ]   66.9MB/104.8MB
103930488ac4: Downloading [>                                                  ]  125.5kB/12.07MB
97466eb1c2ad: Downloading [====================>                              ]  24.59MB/60.48MB
069d51b0476d: Downloading [=================================>                 ]  70.65MB/104.8MB
103930488ac4: Downloading [=======>                                           ]  1.819MB/12.07MB
97466eb1c2ad: Downloading [======================>                            ]  26.75MB/60.48MB
069d51b0476d: Downloading [===================================>               ]  74.36MB/104.8MB
103930488ac4: Downloading [================>                                  ]  3.911MB/12.07MB
97466eb1c2ad: Downloading [=======================>                           ]  28.89MB/60.48MB
069d51b0476d: Downloading [====================================>              ]  77.02MB/104.8MB
103930488ac4: Downloading [=========================>                         ]  6.273MB/12.07MB
97466eb1c2ad: Downloading [=========================>                         ]  31.01MB/60.48MB
069d51b0476d: Downloading [======================================>            ]  81.27MB/104.8MB
103930488ac4: Downloading [=================================>                 ]    8.1MB/12.07MB
97466eb1c2ad: Downloading [==========================>                        ]  32.63MB/60.48MB
069d51b0476d: Downloading [=======================================>           ]  83.39MB/104.8MB
103930488ac4: Downloading [===================================>               ]   8.62MB/12.07MB
97466eb1c2ad: Downloading [===========================>                       ]  33.17MB/60.48MB
069d51b0476d: Downloading [========================================>          ]  84.47MB/104.8MB
103930488ac4: Downloading [=======================================>           ]  9.534MB/12.07MB
97466eb1c2ad: Downloading [============================>                      ]  34.77MB/60.48MB
103930488ac4: Downloading [===========================================>       ]  10.57MB/12.07MB
069d51b0476d: Downloading [=========================================>         ]  86.59MB/104.8MB
97466eb1c2ad: Downloading [=============================>                     ]  35.85MB/60.48MB
103930488ac4: Downloading [================================================>  ]  11.62MB/12.07MB
103930488ac4: Verifying Checksum
103930488ac4: Download complete
069d51b0476d: Downloading [=========================================>         ]  87.65MB/104.8MB
97466eb1c2ad: Downloading [==============================>                    ]  36.93MB/60.48MB
97466eb1c2ad: Downloading [================================>                  ]  39.62MB/60.48MB
069d51b0476d: Downloading [===========================================>       ]  90.32MB/104.8MB
97466eb1c2ad: Downloading [===================================>               ]  42.82MB/60.48MB
069d51b0476d: Downloading [============================================>      ]  94.03MB/104.8MB
069d51b0476d: Downloading [===============================================>   ]  98.82MB/104.8MB
97466eb1c2ad: Downloading [=====================================>             ]  44.95MB/60.48MB
069d51b0476d: Downloading [=================================================> ]  103.6MB/104.8MB
97466eb1c2ad: Downloading [======================================>            ]  47.09MB/60.48MB
069d51b0476d: Verifying Checksum
069d51b0476d: Download complete
97466eb1c2ad: Downloading [=========================================>         ]  49.78MB/60.48MB
97466eb1c2ad: Downloading [===========================================>       ]  52.99MB/60.48MB
069d51b0476d: Extracting [>                                                  ]  557.1kB/104.8MB
97466eb1c2ad: Downloading [===============================================>   ]  57.24MB/60.48MB
069d51b0476d: Extracting [>                                                  ]  1.671MB/104.8MB
97466eb1c2ad: Verifying Checksum
97466eb1c2ad: Download complete
069d51b0476d: Extracting [=>                                                 ]  3.899MB/104.8MB
069d51b0476d: Extracting [===>                                               ]  7.242MB/104.8MB
069d51b0476d: Extracting [====>                                              ]   9.47MB/104.8MB
069d51b0476d: Extracting [=====>                                             ]  12.26MB/104.8MB
069d51b0476d: Extracting [======>                                            ]  14.48MB/104.8MB
069d51b0476d: Extracting [========>                                          ]  17.27MB/104.8MB
069d51b0476d: Extracting [=========>                                         ]   19.5MB/104.8MB
069d51b0476d: Extracting [==========>                                        ]  22.28MB/104.8MB
069d51b0476d: Extracting [===========>                                       ]  24.51MB/104.8MB
069d51b0476d: Extracting [============>                                      ]  26.74MB/104.8MB
069d51b0476d: Extracting [=============>                                     ]  28.97MB/104.8MB
069d51b0476d: Extracting [==============>                                    ]   31.2MB/104.8MB
069d51b0476d: Extracting [===============>                                   ]  33.42MB/104.8MB
069d51b0476d: Extracting [=================>                                 ]  35.65MB/104.8MB
069d51b0476d: Extracting [==================>                                ]  38.44MB/104.8MB
069d51b0476d: Extracting [===================>                               ]  40.11MB/104.8MB
069d51b0476d: Extracting [===================>                               ]  41.78MB/104.8MB
069d51b0476d: Extracting [=====================>                             ]  45.68MB/104.8MB
069d51b0476d: Extracting [=======================>                           ]  49.58MB/104.8MB
069d51b0476d: Extracting [=========================>                         ]  53.48MB/104.8MB
069d51b0476d: Extracting [===========================>                       ]  57.38MB/104.8MB
069d51b0476d: Extracting [============================>                      ]  60.16MB/104.8MB
069d51b0476d: Extracting [==============================>                    ]  64.06MB/104.8MB
069d51b0476d: Extracting [================================>                  ]  67.96MB/104.8MB
069d51b0476d: Extracting [=================================>                 ]  70.75MB/104.8MB
069d51b0476d: Extracting [==================================>                ]  72.42MB/104.8MB
069d51b0476d: Extracting [===================================>               ]   75.2MB/104.8MB
069d51b0476d: Extracting [====================================>              ]  77.43MB/104.8MB
069d51b0476d: Extracting [=====================================>             ]   79.1MB/104.8MB
069d51b0476d: Extracting [======================================>            ]  81.33MB/104.8MB
069d51b0476d: Extracting [========================================>          ]  84.12MB/104.8MB
069d51b0476d: Extracting [=========================================>         ]  88.01MB/104.8MB
069d51b0476d: Extracting [===========================================>       ]   90.8MB/104.8MB
069d51b0476d: Extracting [============================================>      ]  93.03MB/104.8MB
069d51b0476d: Extracting [=============================================>     ]  95.26MB/104.8MB
069d51b0476d: Extracting [==============================================>    ]  97.48MB/104.8MB
069d51b0476d: Extracting [===============================================>   ]  99.16MB/104.8MB
069d51b0476d: Extracting [================================================>  ]  101.4MB/104.8MB
069d51b0476d: Extracting [================================================>  ]  102.5MB/104.8MB
069d51b0476d: Extracting [=================================================> ]  103.1MB/104.8MB
069d51b0476d: Extracting [==================================================>]  104.8MB/104.8MB
069d51b0476d: Pull complete
ee7094de4c48: Extracting [===================>                               ]  32.77kB/85.88kB
ee7094de4c48: Extracting [==================================================>]  85.88kB/85.88kB
ee7094de4c48: Extracting [==================================================>]  85.88kB/85.88kB
ee7094de4c48: Pull complete
200b63deca0b: Extracting [==================================================>]     417B/417B
200b63deca0b: Extracting [==================================================>]     417B/417B
200b63deca0b: Pull complete
072730bdc14d: Extracting [>                                                  ]  32.77kB/2.405MB
072730bdc14d: Extracting [========================>                          ]   1.18MB/2.405MB
072730bdc14d: Extracting [==================================================>]  2.405MB/2.405MB
072730bdc14d: Pull complete
97466eb1c2ad: Extracting [>                                                  ]  557.1kB/60.48MB
97466eb1c2ad: Extracting [===>                                               ]  3.899MB/60.48MB
97466eb1c2ad: Extracting [=====>                                             ]  6.128MB/60.48MB
97466eb1c2ad: Extracting [=======>                                           ]  8.913MB/60.48MB
97466eb1c2ad: Extracting [========>                                          ]  10.03MB/60.48MB
97466eb1c2ad: Extracting [=========>                                         ]  11.14MB/60.48MB
97466eb1c2ad: Extracting [==========>                                        ]  12.26MB/60.48MB
97466eb1c2ad: Extracting [===========>                                       ]  13.37MB/60.48MB
97466eb1c2ad: Extracting [===========>                                       ]  14.48MB/60.48MB
97466eb1c2ad: Extracting [=============>                                     ]  16.15MB/60.48MB
97466eb1c2ad: Extracting [==============>                                    ]  17.83MB/60.48MB
97466eb1c2ad: Extracting [================>                                  ]   19.5MB/60.48MB
97466eb1c2ad: Extracting [=================>                                 ]  21.17MB/60.48MB
97466eb1c2ad: Extracting [==================>                                ]  22.84MB/60.48MB
97466eb1c2ad: Extracting [===================>                               ]   23.4MB/60.48MB
97466eb1c2ad: Extracting [=====================>                             ]  25.62MB/60.48MB
97466eb1c2ad: Extracting [======================>                            ]   27.3MB/60.48MB
97466eb1c2ad: Extracting [=======================>                           ]  27.85MB/60.48MB
97466eb1c2ad: Extracting [=======================>                           ]  28.97MB/60.48MB
97466eb1c2ad: Extracting [=========================>                         ]  30.64MB/60.48MB
97466eb1c2ad: Extracting [==========================>                        ]  32.31MB/60.48MB
97466eb1c2ad: Extracting [============================>                      ]  34.54MB/60.48MB
97466eb1c2ad: Extracting [=============================>                     ]  36.21MB/60.48MB
97466eb1c2ad: Extracting [==============================>                    ]  37.32MB/60.48MB
97466eb1c2ad: Extracting [===============================>                   ]  37.88MB/60.48MB
97466eb1c2ad: Extracting [================================>                  ]  39.55MB/60.48MB
97466eb1c2ad: Extracting [=================================>                 ]  40.67MB/60.48MB
97466eb1c2ad: Extracting [==================================>                ]  41.78MB/60.48MB
97466eb1c2ad: Extracting [===================================>               ]  42.89MB/60.48MB
97466eb1c2ad: Extracting [====================================>              ]  44.56MB/60.48MB
97466eb1c2ad: Extracting [======================================>            ]  46.24MB/60.48MB
97466eb1c2ad: Extracting [=======================================>           ]  47.91MB/60.48MB
97466eb1c2ad: Extracting [========================================>          ]  49.58MB/60.48MB
97466eb1c2ad: Extracting [==========================================>        ]  51.25MB/60.48MB
97466eb1c2ad: Extracting [===========================================>       ]  52.92MB/60.48MB
97466eb1c2ad: Extracting [============================================>      ]  54.03MB/60.48MB
97466eb1c2ad: Extracting [=============================================>     ]  55.15MB/60.48MB
97466eb1c2ad: Extracting [==============================================>    ]  56.26MB/60.48MB
97466eb1c2ad: Extracting [===============================================>   ]  57.38MB/60.48MB
97466eb1c2ad: Extracting [================================================>  ]  58.49MB/60.48MB
97466eb1c2ad: Extracting [=================================================> ]   59.6MB/60.48MB
97466eb1c2ad: Extracting [==================================================>]  60.48MB/60.48MB
97466eb1c2ad: Pull complete
103930488ac4: Extracting [>                                                  ]  131.1kB/12.07MB
103930488ac4: Extracting [=>                                                 ]  393.2kB/12.07MB
103930488ac4: Extracting [=====>                                             ]  1.311MB/12.07MB
103930488ac4: Extracting [========>                                          ]  2.097MB/12.07MB
103930488ac4: Extracting [==========>                                        ]   2.49MB/12.07MB
103930488ac4: Extracting [============>                                      ]  3.015MB/12.07MB
103930488ac4: Extracting [===============>                                   ]  3.801MB/12.07MB
103930488ac4: Extracting [===================>                               ]  4.588MB/12.07MB
103930488ac4: Extracting [=====================>                             ]  5.112MB/12.07MB
103930488ac4: Extracting [======================>                            ]  5.505MB/12.07MB
103930488ac4: Extracting [========================>                          ]  5.898MB/12.07MB
103930488ac4: Extracting [===========================>                       ]  6.554MB/12.07MB
103930488ac4: Extracting [==============================>                    ]   7.34MB/12.07MB
103930488ac4: Extracting [================================>                  ]  7.864MB/12.07MB
103930488ac4: Extracting [===================================>               ]   8.52MB/12.07MB
103930488ac4: Extracting [===================================>               ]  8.651MB/12.07MB
103930488ac4: Extracting [====================================>              ]  8.913MB/12.07MB
103930488ac4: Extracting [======================================>            ]  9.306MB/12.07MB
103930488ac4: Extracting [=======================================>           ]  9.568MB/12.07MB
103930488ac4: Extracting [========================================>          ]   9.83MB/12.07MB
103930488ac4: Extracting [=========================================>         ]  10.09MB/12.07MB
103930488ac4: Extracting [==========================================>        ]  10.35MB/12.07MB
103930488ac4: Extracting [===========================================>       ]  10.62MB/12.07MB
103930488ac4: Extracting [=============================================>     ]  11.01MB/12.07MB
103930488ac4: Extracting [==============================================>    ]  11.14MB/12.07MB
103930488ac4: Extracting [===============================================>   ]   11.4MB/12.07MB
103930488ac4: Extracting [==================================================>]  12.07MB/12.07MB
103930488ac4: Pull complete
Digest: sha256:6b647484e0a9e9c332e1fc620845d89974cbff3e9008609dbe4a4785f8cfc054
Status: Downloaded newer image for public.ecr.aws/lambda/python:3.9 ---> 792fdc65bb1f
Step 2/5 : COPY single_store/single_store_gamestate ./
---> c0bc9dae748a
Step 3/5 : COPY lambda_utils/src ./
---> 6c26b5224202
Step 4/5 : RUN python3.9 -m pip install -r requirements.txt
---> Running in 5a2374e9fa0d
Collecting requests
 Downloading requests-2.28.2-py3-none-any.whl (62 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 KB 547.4 kB/s eta 0:00:00
Collecting singlestoredb
 Downloading singlestoredb-0.5.4-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (214 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 214.2/214.2 KB 1.8 MB/s eta 0:00:00
Collecting redis~=4.5.3
 Downloading redis-4.5.4-py3-none-any.whl (238 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 238.9/238.9 KB 6.6 MB/s eta 0:00:00
Collecting kafka-python
 Downloading kafka_python-2.0.2-py2.py3-none-any.whl (246 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 246.5/246.5 KB 8.6 MB/s eta 0:00:00
Collecting sshtunnel
 Downloading sshtunnel-0.4.0-py2.py3-none-any.whl (24 kB)
Collecting urllib3<1.27,>=1.21.1
 Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.9/140.9 KB 9.6 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
 Downloading charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.2/199.2 KB 6.2 MB/s eta 0:00:00
Collecting idna<4,>=2.5
 Downloading idna-3.4-py3-none-any.whl (61 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 2.8 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
 Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 KB 4.1 MB/s eta 0:00:00
Collecting build
 Downloading build-0.10.0-py3-none-any.whl (17 kB)
Collecting sqlparams
 Downloading sqlparams-5.1.0-py3-none-any.whl (16 kB)
Collecting wheel
 Downloading wheel-0.40.0-py3-none-any.whl (64 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.5/64.5 KB 6.6 MB/s eta 0:00:00
Collecting PyJWT
 Downloading PyJWT-2.6.0-py3-none-any.whl (20 kB)
Collecting async-timeout>=4.0.2
 Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting paramiko>=2.7.2
 Downloading paramiko-3.1.0-py3-none-any.whl (211 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 211.2/211.2 KB 6.6 MB/s eta 0:00:00
Collecting bcrypt>=3.2
 Downloading bcrypt-4.0.1-cp36-abi3-manylinux_2_24_x86_64.whl (593 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 593.2/593.2 KB 2.2 MB/s eta 0:00:00
Collecting cryptography>=3.3
 Downloading cryptography-40.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 7.0 MB/s eta 0:00:00
Collecting pynacl>=1.5
 Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 KB 8.2 MB/s eta 0:00:00
Collecting pyproject_hooks
 Downloading pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)
Collecting packaging>=19.0
 Downloading packaging-23.1-py3-none-any.whl (48 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 KB 1.9 MB/s eta 0:00:00
Collecting tomli>=1.1.0
 Downloading tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting cffi>=1.12
 Downloading cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.2/441.2 KB 8.0 MB/s eta 0:00:00
Collecting pycparser
 Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 KB 5.4 MB/s eta 0:00:00
Installing collected packages: kafka-python, wheel, urllib3, tomli, sqlparams, PyJWT, pycparser, packaging, idna, charset-normalizer, certifi, bcrypt, async-timeout, requests, redis, pyproject_hooks, cffi, pynacl, cryptography, build, singlestoredb, paramiko, sshtunnel
Successfully installed PyJWT-2.6.0 async-timeout-4.0.2 bcrypt-4.0.1 build-0.10.0 certifi-2022.12.7 cffi-1.15.1 charset-normalizer-3.1.0 cryptography-40.0.2 idna-3.4 kafka-python-2.0.2 packaging-23.1 paramiko-3.1.0 pycparser-2.21 pynacl-1.5.0 pyproject_hooks-1.0.0 redis-4.5.4 requests-2.28.2 singlestoredb-0.5.4 sqlparams-5.1.0 sshtunnel-0.4.0 tomli-2.0.1 urllib3-1.26.15 wheel-0.40.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 22.0.4; however, version 23.1 is available.
You should consider upgrading via the '/var/lang/bin/python3.9 -m pip install --upgrade pip' command.
Removing intermediate container 5a2374e9fa0d
---> 8677af17b3bd
Step 5/5 : CMD ["app.lambda_handler"]
---> Running in cc6b0839804a
Removing intermediate container cc6b0839804a
---> c4bd563165b8
Successfully built c4bd563165b8
Successfully tagged singlestorefunction:v1


Build Succeeded

Built Artifacts  : .aws-sam/build
Built Template   : .aws-sam/build/template.yaml

Commands you can use next
=========================
[*] Validate SAM template: sam validate
[*] Invoke Function: sam local invoke
[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch
[*] Deploy: sam deploy --guided
/usr/local/bin/sam local invoke SingleStoreFunction --template /Users/yahel/SlateApps/aws/lambda/single_store/single_store_gamestate/.aws-sam/build/template.yaml --event "/private/var/folders/94/tfyd42c12v35p2q2yrl3r9n80000gn/T/[Local] SingleStoreFunction-event1.json" --debugger-path /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev --debug-args "/var/lang/bin/python3.9 -u /tmp/lambci_debug_files/pydevd.py --multiprocess --port 59912 --file /var/runtime/bootstrap.py" --debug-port 59912
Invoking Container created from singlestorefunction:v1
Local image was not found.
Removing rapid images for repo singlestorefunction
Building image.................
Using local image: singlestorefunction:rapid-x86_64.

START RequestId: a71bc71b-f97b-4e40-bf28-203e9779852d Version: $LATEST
SyntaxError: Non-UTF-8 code starting with '\x96' in file /var/lang/bin/python3.9 on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
19 Apr 2023 08:44:45,695 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 1 InvokeID=
SyntaxError: Non-UTF-8 code starting with '\x96' in file /var/lang/bin/python3.9 on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
END RequestId: 2260543a-01bb-4d35-b981-15a23c963a08
REPORT RequestId: 2260543a-01bb-4d35-b981-15a23c963a08	Init Duration: 0.33 ms	Duration: 47.33 ms	Billed Duration: 48 ms	Memory Size: 128 MB	Max Memory Used: 128 MB

@ghost
Copy link

ghost commented Apr 27, 2023

Same setup, same issue

@rli
Copy link
Contributor

rli commented Apr 28, 2023

I am unable to reproduce this.
Does the same thing happen when manually running sam invoke outside of the IDE?

Could you share a source file that has the bare minimum needed to reproduce this error?

@ghost
Copy link

ghost commented Apr 29, 2023

@Yahel-B try to remove Runtime: python3.9 from SingleStoreFunction definition in template.
According to the docs it seems to be the valid runtime option, but for me it's exactly the reason of the error.
fyi @rli

@Yahel-B
Copy link
Author

Yahel-B commented Apr 30, 2023

@viktor-zinchenko This actually helped! Thank you so much, I've been on this for a long time

@Yahel-B Yahel-B closed this as completed Apr 30, 2023
@rli rli removed the needs-response Waiting on additional info and feedback from GitHub community. (no auto closure) label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance General information and guidance, answers to FAQs, or recommended best practices/resources.
Projects
None yet
Development

No branches or pull requests

2 participants