title: ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' When using AWS Lambda and Python
body: <p>I'm currently trying to set up a basic Lambda function in python using AWS CDK and Python, and want to be able to include external libraries in my Lambda code. This is what I've got so far:</p>
  <pre><code>from constructs import Construct
  import aws_cdk as core
  from aws_cdk import (
      Stack,
      aws_lambda as _lambda,
      aws_apigateway as apigw,
  )
  
  
  class SportsTeamGeneratorStack(Stack):
  
      def __init__(self, scope: Construct, id: str, **kwargs) -&gt; None:
          super().__init__(scope, id, **kwargs)
          
          my_lambda = _lambda.Function(self, 'HelloHandler',
              runtime=_lambda.Runtime.PYTHON_3_9,
                  code=_lambda.Code.from_asset(&quot;lambda&quot;,
                      bundling= core.BundlingOptions(
                          image=_lambda.Runtime.PYTHON_3_9.bundling_image,
                          command=[
                              &quot;bash&quot;, &quot;-c&quot;,
                              &quot;pip install --no-cache -r requirements.txt -t /asset-output &amp;&amp; cp -au . /asset-output&quot;
                          ],
                      ),
                  ),
              handler='hello.handler',
          )
  
          apigw.LambdaRestApi(
              self, 'Endpoint',
              handler=my_lambda,
          )
  </code></pre>
  <p>Whenever I run cdk synth just for sanity, I'm getting this error: ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'. I'm brand new to using docker and AWS Lambda, but I've seen something about creating a docker file and copying over files to the docker image in another post, although I'm not entirely sure if that applies when doing things with AWS as this source:</p>
  <p><a href="https://docs.aws.amazon.com/lambda/latest/dg/python-image.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/lambda/latest/dg/python-image.html</a></p>
  <p>says that &quot;AWS provides a Dockerfile for each of the base images to help with bundling your container image&quot;. I have enabled file sharing for the top level project directory using docker, so I don't think that the issue. Also I'm a bit confused if I have to use Amazon ECR here or if this will allow me to include external dependencies in my Lambda code. I'm assuming I somehow have to just bring in the requirements.txt file into the docker image template provided by AWS, but not sure how to do that. Any help is greatly appreciated.</p>