keatontaylor / alexa-actions

A README and associated code to get actionable notifications setup for Alexa devices.
GNU General Public License v3.0
399 stars 187 forks source link

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

Closed srescio closed 7 months ago

srescio commented 8 months ago

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

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 commented 8 months ago

worth mentioning that during skill setup I also was unable to import via GH link and had the same error as https://github.com/keatontaylor/alexa-actions/issues/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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

https://github.com/keatontaylor/alexa-actions/assets/6099979/44edde67-f197-4e73-9b08-de029f7d6679

Krispkiwi commented 8 months ago

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 commented 8 months ago

Guys is this is unrelated to the original issue. Please move to a discussion chat created https://github.com/keatontaylor/alexa-actions/discussions/232.

@Krispkiwi @srescio

DEADSEC-SECURITY commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

https://github.com/keatontaylor/alexa-actions/tree/233-bug-no-module-named-isodate-dependencies-from-requirementstxt-not-installed

srescio commented 8 months ago

@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 commented 8 months ago

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 commented 8 months ago

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

srescio commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 7 months ago

That's one workaround but not ideal.

DEADSEC-SECURITY commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

same

vfranchi commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@vfranchi it worked 🚀

Screenshot 2024-02-22 alle 21 54 14
Krispkiwi commented 7 months ago

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

vfranchi commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

i confirm it works, thanks to all.

DEADSEC-SECURITY commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

Wiki updated