{"id":1954,"date":"2020-05-22T18:20:50","date_gmt":"2020-05-22T15:20:50","guid":{"rendered":"https:\/\/artem.services\/?p=1952"},"modified":"2020-05-22T18:25:21","modified_gmt":"2020-05-22T15:25:21","slug":"1954","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1954&lang=en","title":{"rendered":"FIX ERROR &#8212; AWS Lambda Python: &quot;main() takes 0 positional arguments but 2 were given&quot;"},"content":{"rendered":"<p>When trying to execute the <strong>Lambda Python<\/strong> function, the following error occurs:<\/p>\n<pre>{\r\n  \"errorMessage\": \"main() takes 0 positional arguments but 2 were given\",\r\n  \"errorType\": \"TypeError\",\r\n  \"stackTrace\": [\r\n    \"  File \\\"\/var\/runtime\/bootstrap.py\\\", line 131, in handle_event_request\\n    response = request_handler(event, lambda_context)\\n\"\r\n  ]\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>Solution:<\/h3>\n<p>From the message, we see that we use the &quot;<strong>main<\/strong>&quot; function as a handler, which has no incoming arguments.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef main():\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>And to run, you need a handler of 2 arguments &quot;<strong>event<\/strong>&quot; and &quot;<strong>context<\/strong>&quot;, so you need to bring the function declaration to the following form:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef main(event, context):\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When trying to execute the Lambda Python function, the following error occurs: { &quot;errorMessage&quot;: &quot;main() takes 0 positional arguments but 2 were given&quot;, &quot;errorType&quot;: &quot;TypeError&quot;, &quot;stackTrace&quot;: [ &quot; File \\&quot;\/var\/runtime\/bootstrap.py\\&quot;, line 131, in handle_event_request\\n response = request_handler(event, lambda_context)\\n&quot; ] } &nbsp; Solution: From the message, we see that we use the &quot;main&quot; function as a &hellip; <a href=\"https:\/\/artem.services\/?p=1954&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;FIX ERROR &#8212; AWS Lambda Python: &quot;main() takes 0 positional arguments but 2 were given&quot;&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[357],"tags":[543,361,365,885,1527,1529],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1954"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1954"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1954\/revisions"}],"predecessor-version":[{"id":1956,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1954\/revisions\/1956"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}