title: AWS Lambda unable to import module from layer
body: <p>I am trying to create a Lambda function with a dependency to load from a layer. I thought I had this working when I deployed it a while ago, but I keep getting this error now, and I can't figure out what I am doing wrong here.</p>
  <p>I am trying to create a layer with pyopenssl for python 3.x. My understanding is that the dependencies should be installed into a &quot;python&quot; top level directory before being zipped for the layer. Here is how the layer is created:</p>
  <p>requirements.txt:</p>
  <pre><code>$ echo &quot;pyopenssl&quot; &gt; requirements.txt
  pip install -t python -r requirements.txt
  python -c &quot;import shutil;shutil.make_archive('layer-openssl','zip','python')&quot;
  </code></pre>
  <p>The python command is the equivalent of creating a zip file from the <code>python</code> directory. e.g. if I create a temp directory and unzip in there, the top level directory is <code>python</code> with <code>OpenSSL</code> and all the transitive dependencies in it (cffi, cryptography, etc).</p>
  <p>Python version is 3.8, and pip is 20.0 from python 3.8 too.</p>
  <p>I then create the layer (e.g. for testing at the moment, I am doing this manually in the web console) - have marked the layer as compatible with 3.6, 3.7 and 3.8 versions.</p>
  <p>Then I create a Python 3.8 function, and add an import:</p>
  <pre><code>from OpenSSL.crypto import load_certificate
  
  def lambda_handler(event, context):
    return true
  
  </code></pre>
  <p>And this gives me an error: <code>Unable to import module 'lambda_function': No module named OpenSSL.crypto</code></p>
  <p>I have tried publishing a 2nd version of the layer marked as compatible with Python 2.7, and then created a 2.7 runtime function with the same import, but it fails too.</p>
  <p>Is there anything obvious that I am doing wrong that I am missing? Should adding OpenSSL to <code>python</code> be sufficient - i am pretty sure i had this working with python 3.8 a short while ago, and am using the same deployment code on this.</p>