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

[Bug]: No module named 'isodate' - dependencies from requirements.txt not installed #233

Closed
2 tasks done
srescio opened this issue Feb 13, 2024 · 38 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@srescio
Copy link

srescio commented Feb 13, 2024

Did you check our FAQ and Issue/PR for similar issues?

  • FAQ checked!
  • Issues/PR checked!

Contact Details

simone.rescio@gmail.com

What happened?

Followed all prerequisite and configs steps, Dev skill is linked and visible by echo,
Upon invocation it should reply with the JSON payload stored in my homeassistant input_text helper
instead it still complains of the skills response,
cloudwatch logs contain runtime errors about imports not found

Version

0.9.1

What Alexa device are you using?

Echo

What other Alexa device are you using?

No response

Relevant log output

INIT_START Runtime Version: python:3.8.v41	Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:6a6066b910d3e488caac03c39e790a2dcaf5ee5423bd1a26e8b04e76be566212
START RequestId: 4fdada97-11e4-444e-8584-55e20e9d65a5 Version: 9
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'isodate'
Traceback (most recent call last):
END RequestId: 4fdada97-11e4-444e-8584-55e20e9d65a5
REPORT RequestId: 4fdada97-11e4-444e-8584-55e20e9d65a5	Duration: 2.37 ms	Billed Duration: 3 ms	Memory Size: 512 MB	Max Memory Used: 40 MB	Init Duration: 139.11 ms
@srescio srescio added the bug Something isn't working label Feb 13, 2024
@srescio
Copy link
Author

srescio commented Feb 13, 2024

worth mentioning that during skill setup I also was unable to import via GH link and had the same error as #230
my language is italian, which is supposedly supported
so instead I downloaded the repo as zip and uploaded that, not sure this might have played a role or not

@leonardoph2
Copy link

Same here. Tried to import via GitHub too, but results on error...
Reading the logs, same error: "[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'isodate'".
Btw, it happens in English (can't import via Github link) and also in Portuguese (BR).

@Krispkiwi
Copy link

worth mentioning that during skill setup I also was unable to import via GH link and had the same error as #230 my language is italian, which is supposedly supported so instead I downloaded the repo as zip and uploaded that, not sure this might have played a role or not

How did you upload it? I dont see that option

@srescio
Copy link
Author

srescio commented Feb 15, 2024

How did you upload it? I dont see that option

when it gives you the error about failing to provision resources ignore the error and go ahead with creating the skill, then go into the code editor having created "from scratch" and select the option to upload it, will overwrite the "hello world" files

Registrazione.schermo.2024-02-15.alle.23.06.00.mp4

@Krispkiwi
Copy link

Krispkiwi commented Feb 15, 2024

How did you upload it? I dont see that option

when it gives you the error about failing to provision resources ignore the error and go ahead with creating the skill, then go into the code editor having created "from scratch" and select the option to upload it, will overwrite the "hello world" files

Registrazione.schermo.2024-02-15.alle.23.06.00.mp4

Thanks, sadly this doesn't solve the error by the looks of things, the tests are still failing.

@DEADSEC-SECURITY
Copy link
Collaborator

DEADSEC-SECURITY commented Feb 20, 2024

Guys is this is unrelated to the original issue. Please move to a discussion chat created #232.

@Krispkiwi @srescio

@DEADSEC-SECURITY
Copy link
Collaborator

worth mentioning that during skill setup I also was unable to import via GH link and had the same error as #230 my language is italian, which is supposedly supported so instead I downloaded the repo as zip and uploaded that, not sure this might have played a role or not

There are 2 issues here guys. So first there is languages not being supported currently like Indian. The second one is with importing because of library that is not installing.

I suspect I know whats the issue, let me confirm if its the issue indeed

@SkyCatcher2
Copy link

worth mentioning that during skill setup I also was unable to import via GH link and had the same error as #230 my language is italian, which is supposedly supported so instead I downloaded the repo as zip and uploaded that, not sure this might have played a role or not

There are 2 issues here guys. So first there is languages not being supported currently like Indian. The second one is with importing because of library that is not installing.

I suspect I know whats the issue, let me confirm if its the issue indeed

I dont know anything about AWS (first day) but I see the logs point to missing dependencies. Is AWS not supposed to import the packages on build?

2024-02-21T01:31:51.224+01:00
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'isodate'
Traceback (most recent call last):

The third-party imports are failing

@DEADSEC-SECURITY
Copy link
Collaborator

Ok so got some news. The issue seems to be with isodate library specifically. My guess is that AWS is not compiling isodate properly in the backend. The solution will be so remove isodate and make my own iso to seconds converter. Hot fix will come soon

@DEADSEC-SECURITY
Copy link
Collaborator

Ok so fix is done. Please try the code in the branch associated with this Issue and let me know if it works or not for you guys. Hope to get some feedback before merging into master

@DEADSEC-SECURITY
Copy link
Collaborator

@srescio
Copy link
Author

srescio commented Feb 21, 2024

@DEADSEC-SECURITY tested now, good news is the isodate error is gone 👍🏻
bad news is, now it complains about something else 😅

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'sentry_sdk'
Traceback (most recent call last):

@srescio
Copy link
Author

srescio commented Feb 21, 2024

the libs imports are not working, doesnt matter how you place the lambda code into the skill,
it definitely throws on that as its directly referenced
I tried looking for instances of the others libraries mentioned in requirements.txt like the boto3 but it doesn't seem to be ever imported anywhere? but maybe it has to be present implicitly for some aws blackbox magic am not aware of

@DEADSEC-SECURITY
Copy link
Collaborator

This is because aws bosted from python 3.7 to 3.8. It must've messed with the environments for python3.

@srescio
Copy link
Author

srescio commented Feb 21, 2024

I dont seems to have the option to downgrade or select a different python version upon skill creation, wish they put some migration guide or something but cant find anything by sheer googling, one would hope they d respect the version specified in the toml file but that doesn't seem the case...

@DEADSEC-SECURITY
Copy link
Collaborator

I'm trying to weigh my options because there are solutions but those same solutions are too complicated for non-developers and will make it way harder to use

@vfranchi
Copy link

I was able to make it work, but I had to, in my case, Export do VSCode. It creates a local git with the code on your machine.

Then, using pip, I've installed dependencies manually and push back the code with libraries.
pip install -t . isodate==0.6.1 pydantic==1.10.4 sentry-sdk==1.32.0

After that, I have all necessary libraries in place and I can do the Hello World testing of the skill.

@DEADSEC-SECURITY
Copy link
Collaborator

That's one workaround but not ideal.

@DEADSEC-SECURITY
Copy link
Collaborator

Also if any lib is compiled it wont work @vfranchi because compiling in windows wont work in lambda which runs linux. Thats one of the reasons Im trying to avoid that

@vfranchi
Copy link

Maybe this could work. I created a ZIP file of my lambda folder, with everything needed to run the code. Amazon has a limit of 100 files per Import from a Zip file, so I had to do the import in parts. I replicated these steps and the Skill worked sucessfully:

  1. Created a new Skill from scratch
  2. Used the Import Code button
  3. Select the ZIP file, included all lambda folder but unchecked the integrations folder from sentry_sdk package
  4. Used the Import Code button again, same ZIP file
  5. Selected only the integrations folder from sentry_sdk package
  6. Tested the Skill and it worked

@DEADSEC-SECURITY If you want I can provide you with this ZIP file, or if you prefer I'm sure you can create one yourself. I think this is a good approach for non-developers as well. It'll require just a manual import of the code.

@DEADSEC-SECURITY
Copy link
Collaborator

For now if anyone wants to replicate @vfranchi go ahead. I will keep this issue open until we come up with something more permanent. We have a guy contacting AWS, I might do the same and I'm keeping on researching it too.

@vfranchi feel free to add the zip file to this issue for people hwo want to implement the current workaround

@gioefede90
Copy link

@vfranchi and @DEADSEC-SECURITY thanks for keep in touch with the problem.
if possible to have vfrachi's zip i'd like to test if it works.

@Krispkiwi
Copy link

same

@vfranchi
Copy link

alexa-actions.zip

  1. Create a New Skill from scratch, if you don't have one already.
    1.1 Follow the wiki guide up until the Templates section.
    1.2 Select Start from Scratch
    image
  2. Open your Skill and go to Code page
  3. Use the Import Code button
    image
  4. Select the ZIP file, select all lambda folder but uncheck the integrations folder from sentry_sdk package
    image
  5. Use the Import Code button again, selecting same ZIP file
  6. Select only the integrations folder from sentry_sdk package
    image
  7. You should have everything necessary to continue testing the Skill with the Wiki guide

You will need to update your Invocation Skill Name and use the JSON Editor to update the Skill intents
https://github.com/keatontaylor/alexa-actions/blob/master/skill-package/interactionModels/custom/en-US.json

@Krispkiwi
Copy link

Krispkiwi commented Feb 22, 2024

Testing result: When I say yes or no it now states "You just triggered hello world intent" and home assistant doesn't pick up any event

@srescio
Copy link
Author

srescio commented Feb 22, 2024

@vfranchi it worked 🚀
Screenshot 2024-02-22 alle 21 54 14

@Krispkiwi
Copy link

That part works but when you try to do yes or no responses testing the functionality, it doesn't.

@vfranchi
Copy link

Testing result: When I say yes or no it now states "You just triggered hello world intent" and home assistant doesn't pick up any event

Did you click the Deploy button on the Code page?

@Krispkiwi
Copy link

Testing result: When I say yes or no it now states "You just triggered hello world intent" and home assistant doesn't pick up any event

Did you click the Deploy button on the Code page?

Yes

@vfranchi
Copy link

Shouldn't be related to this issue anymore. All libraries are there and the code that makes it work is there as well. You are not seeing the No module named... error anymore.

I can do the Yes or No testing here. It's done entirely on Home Assistant panel:
image

@Krispkiwi
Copy link

Krispkiwi commented Feb 22, 2024

I'll go over the steps I did.
Name: Alexa actionable notifications - English Local
Custom - Alexa hosted python - US West
Start from scratch - Create Skill
Whilst that's creating the hosted skill I added the alexa_actionable_notification helper.
Changed the skill invocation name to actionable notifications
Imported the code except for the integrations folder then imported just the integrations folder then clicked deploy.

Testing "Open actionable notifications" I get there was a problem with the requested skills response
I update the lamba to include my url and token and click deploy
Testing again It picks up the input text but when I reply to it this happens

image

@vfranchi
Copy link

Maybe you've missed the JSON Editor part. Under Build, Interaction Model, JSON Editor. Paste the content of this file there. Hit Save on the top and Build.

Then proceed with the testing guide.

@Krispkiwi
Copy link

Maybe you've missed the JSON Editor part. Under Build, Interaction Model, JSON Editor. Paste the content of this file there. Hit Save on the top and Build.

Then proceed with the testing guide.

That was it, cheers.

@gioefede90
Copy link

i confirm it works, thanks to all.

@DEADSEC-SECURITY
Copy link
Collaborator

Hey guys I just got confirmation that this is the way to go from now on so I will be updating the documentation very soon to reflect the new requirements.

@DEADSEC-SECURITY
Copy link
Collaborator

I figured. Might as well compile the zip files using github actions when a new release is made so you guys can just download the zip files. It should make it a bit easier for noobies

@DEADSEC-SECURITY
Copy link
Collaborator

This is now partially fixed guys.
Now we have a github action to build the zip file for your so in every release we just have to download the compiled zip file for linux. https://github.com/keatontaylor/alexa-actions/releases/tag/v0.12.0

It will be under the name AlexaActionsLinux.zip.

Now last step will be to update the wiki to reflect these changes. If anyone would like to test this new version please feel free to do so and give me some feedback.

@DEADSEC-SECURITY
Copy link
Collaborator

Wiki updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants