0

I have uploaded Paramiko library as a layer in the Lambda function. However, still when I am attempting to import the same, it is giving me the following error:

Response { "errorMessage": "Unable to import module 'lambda_function': No module named 'paramiko'", "errorType": "Runtime.ImportModuleError", "requestId": "8c81ba38-1074-43da-9427-ebad905d8d48", "stackTrace": [] }

Following is the file hierarchy within the upload .zip file:

Python->lib->Python3.6->site packages

The contents in the above location are also uploaded as an image.

On googling another answer, I also tried moving all the contents to the super-parent folder Python, but was still unsuccessful.

Please suggest how to make it work.

TIA.

4
  • How did you create the layer? Commented Nov 29, 2022 at 0:33
  • I first added the library by uploading the zip in the layers of Lambda service. Then I went into my lambda function and added a layer to it and chose custom layer I added previously. Commented Nov 29, 2022 at 8:46
  • This is not how a layer is properly done. Check aws docs on how to do it correctly. Commented Nov 29, 2022 at 8:47
  • Perhaps I am unable to follow the documentation correctly, but I resolved the error by building the zip file on my other system. However, I am getting a new error: "errorMessage": "Unable to import module 'lambda_function': cannot import name 'asn1' from 'cryptography.hazmat.bindings._rust' (unknown location)", I also tried installing the asn1 and cryptography libraries explicitly using the --upgrade option, but that does not seem to work either. So now it is able to find the Paramiko library, but not asn1.pyi which is present in the same location it is searching at in the message. Commented Nov 29, 2022 at 13:33

1 Answer 1

0

I finally resolved it myself.

Turns out I was following all the steps correctly. But being new to AWS, and due to the unavailability of a Linux System, I was using the Windows system, and since Amazon works with Linux in the background, there was a discrepancy. I made use of the EC2 instance for Linux based libraries, and resolved the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.