How To Deploy Python Selenium Script in AWS Lambda in 2022

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ธ.ค. 2024

ความคิดเห็น • 123

  • @minhthieu2466
    @minhthieu2466 2 ปีที่แล้ว +4

    Hello
    I've followed your video carefully and am pretty sure I didn't miss any detail or do anything wrong. However, I got the error:
    "errorMessage": "Unable to import module 'main': No module named 'selenium'",
    "errorType": "Runtime.ImportModuleError",
    "stackTrace": []
    I really hope you can help me with this, I've turn the internet upside down, but so far nothing works

    • @MichaelKitas
      @MichaelKitas  2 ปีที่แล้ว +3

      1. Did you add the selenium layer?
      2. Did you connect the layer to the lambda function?
      3. Did you install specifically selenium 3.8.0 and with python 3.7 version with the correct path command which I have in the description?
      Check those 3, as I faced the same issue before recording the video, and the same checklist applied to me as well.

    • @minhthieu2466
      @minhthieu2466 2 ปีที่แล้ว +1

      @@MichaelKitas Nevermind, thank you so much, now it's working

    • @miclo_ssx
      @miclo_ssx 2 ปีที่แล้ว +1

      @@minhthieu2466 well what was the issue

    • @tektonbuilds
      @tektonbuilds 2 ปีที่แล้ว +1

      @@miclo_ssx he didn't add the selenium layer

    • @AtulKumar-ih2df
      @AtulKumar-ih2df ปีที่แล้ว

      @@minhthieu2466

  • @celeb_life_in_30
    @celeb_life_in_30 ปีที่แล้ว +2

    Can't thank you enough for this, I am gonna write a blog and add this video there.

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Thank you a lot for this 🙂

  • @richardhoppe4991
    @richardhoppe4991 ปีที่แล้ว +2

    Really awesome tutorial, even I was able to get this up and running!

  • @pablorosa2960
    @pablorosa2960 ปีที่แล้ว +2

    what an incredible tutorial, priceless information very hard to find over the internet.

  • @rosoldamian
    @rosoldamian ปีที่แล้ว +2

    SUPERB !! i just need to pay attention to the zip path structure, thanks a lot!

  • @umair.a
    @umair.a ปีที่แล้ว +11

    Hi Michael, can you make another video on selenium using container implementation to build lambda? It would be a life saver! Thanks in advance

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Great suggestion, will make sure to add it to the list

    • @Alleluia_
      @Alleluia_ ปีที่แล้ว

      @@MichaelKitas Yes please!!!! Thanks

    • @MichaelKitas
      @MichaelKitas  3 หลายเดือนก่อน

      Just uploaded a new video which supports any python version: th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

  • @bindureddy6148
    @bindureddy6148 ปีที่แล้ว +7

    Hi Michael,
    Thank you so much for such a good video. Recently AWS lambda announced that lambda will not be maintaining Python3.7 anymore . Need to move my code to python 3.11. Not sure how to do this. Can you please make a video to use selenium chrome driver with python 3.11 in lambda? Or can you suggest me a way to solve this?

    • @bindureddy6148
      @bindureddy6148 ปีที่แล้ว +1

      Please reply Michael

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว +2

      Many requested this, I've added it to the to-do list, will try to make a video asap

    • @AmiUstilovsky
      @AmiUstilovsky ปีที่แล้ว +1

      when will be ready this video?@@MichaelKitas

    • @mikesopinion718
      @mikesopinion718 ปีที่แล้ว +1

      please@@MichaelKitas

    • @MichaelKitas
      @MichaelKitas  3 หลายเดือนก่อน

      Just uploaded a new video which supports any python version: th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

  • @lboesch
    @lboesch 2 ปีที่แล้ว +4

    Hi thanks for the video, this was something that frustrated me in may and dropping it all together. There are plenty of sites with the information, BUT the most important element: this ONLY works with Python 3.7 and Selenium 3.8.
    Following the security mindset, everything back in may was trying to use the latest version =)

    • @sunkun081
      @sunkun081 ปีที่แล้ว

      Agreed with this. Wish it is compatible with all the python and selenium version.

  • @AmiUstilovsky
    @AmiUstilovsky ปีที่แล้ว +4

    I used the same versions but instead I download chromedriver and headless-chromium from s3 to my tmp files (because of the limit size of layers). I got this error: Message: 'chromedriver' executable may have wrong permissions. Do you know how to fix this?

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Check this out: stackoverflow.com/questions/49787327/selenium-on-mac-message-chromedriver-executable-may-have-wrong-permissions

    • @pdfmaker
      @pdfmaker 6 หลายเดือนก่อน

      hey. im facing the exact same issue. were u able to fix it?

  • @austinsketches
    @austinsketches ปีที่แล้ว +2

    How did you manage to make headless-chromium turn from 102,6 MB uncompressed to 5,1 MB uncompressed at the 9:50 mark? It's like the number just changes without any explanation. How are you able to upload headless-chromium and chromedriver without exceeding the Layer size limit of 50MB? The exact same file uncompressed on my system is 100MB as well. I'd prefer not to have to use S3

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Are you using Mac? That’s how much it is compressed using the Mac’s compression (Under 50mb). Using another software would for sure give different results.

  • @شروحاتتقنية-ث7ز
    @شروحاتتقنية-ث7ز 8 หลายเดือนก่อน +2

    Hello bro, Thanks for ur great work , but I got a question
    AWS Lambda end of support for Python 3.7
    so it's not supported anymore at least for layers, do u have another way to get around with this , I would really appreciate this alot!
    Thanks in advance !

    • @MichaelKitas
      @MichaelKitas  7 หลายเดือนก่อน

      Yes, making an updated video this week. Hint, check: AWS SAM CLI

  • @ameeshagupta2559
    @ameeshagupta2559 2 ปีที่แล้ว +2

    Hi, Which selenium version is compatible with Python 3.9 lambda version??

  • @qwerty4r5tgy
    @qwerty4r5tgy ปีที่แล้ว +2

    thank you so much.
    It was my big problem. you saved my time.!

  • @jennydavies6973
    @jennydavies6973 3 หลายเดือนก่อน +1

    Hi Michael, in a few comments you talk about an updated video that doesn't rely on a deprecated version of Python. If this video exists, can you please provide a link here

    • @MichaelKitas
      @MichaelKitas  2 หลายเดือนก่อน

      th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

  • @serggurzhy4622
    @serggurzhy4622 ปีที่แล้ว +2

    Thank you for your work. I want to run Selenium4.8. and Request I have a urllib3 library conflict. what could be the problem?

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Can you send screenshot (send url of screenshot) of the error?

  • @kevinalarconqusipe6666
    @kevinalarconqusipe6666 9 หลายเดือนก่อน +1

    Hi, I have this error: "errorMessage": "2024-03-12T04:26:45.989Z 394e1df8-6683-4e3b-aa9c-da1864b9bba9 Task timed out after 20.01 seconds". I followed all steps but this error appears.

    • @MichaelKitas
      @MichaelKitas  7 หลายเดือนก่อน

      Maybe increase timeout? Probably doesnt have enough time to complete the script

  • @mauriciobertolucci
    @mauriciobertolucci ปีที่แล้ว +2

    Hello, thanks for sharing. I tested it and it worked perfectly as in the video, but I have a question. I couldn't get it to work with newer versions of the libraries. Why does this happen? Today I have several codes implemented with the latest versions and it would be a lot of work to adapt the old versions. Tks

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Many requested this, I've added it to the to-do list, will try to make a video asap

  • @asdfghjkl36958
    @asdfghjkl36958 ปีที่แล้ว +2

    Thanks for sharing this, incredibly helpful!

  • @richardpassett924
    @richardpassett924 ปีที่แล้ว +2

    This is amazing, thank you!

  • @JoshNn-w7b
    @JoshNn-w7b ปีที่แล้ว +2

    Hello, thanks for the video, but but when i am adding the layer of chormdrive there, i got a error 'Layers consume more than the available size of 262144000 bytes'

    • @alexkeila
      @alexkeila ปีที่แล้ว +1

      I have the same issue!! The chromedriver ZIP is a larger file than the ones from the other layers.

    • @JoshNn-w7b
      @JoshNn-w7b ปีที่แล้ว +1

      @@alexkeila I have managed to solve that by using the exact version of selenium , however , the one run on lambda does not have the same result as I run on my local machine

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      You need to use the exact version of selenium as @user-zy7qo3ch1s mentioned.

  • @kkkennnlii
    @kkkennnlii ปีที่แล้ว +1

    aws lambda gonna end support for Python 3.7. Also it seems like the current setup we got cannot be migrated to python 3.11. I tried to migrate but chromedriver couldnt start. How should we go from here, Michael?

    • @kkkennnlii
      @kkkennnlii ปีที่แล้ว

      @MichaelKitas

    • @bindureddy6148
      @bindureddy6148 ปีที่แล้ว

      Let me know if you find a way to work the code in python 3.11

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Many requested this, I've added it to the to-do list, will try to make a video asap

    • @VIKASSAINI007
      @VIKASSAINI007 10 หลายเดือนก่อน

      @@MichaelKitas Still waiting, I guess docker container is the only option

    • @MichaelKitas
      @MichaelKitas  3 หลายเดือนก่อน

      Just uploaded a new video which supports any python version: th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

  • @mrsseeppoo
    @mrsseeppoo ปีที่แล้ว +1

    Hi I want to use undetected-chromedriver in my AWS lambda, which version is compliant with selenium 3.8.0?

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว +1

      I think latest version works: pypi.org/project/undetected-chromedriver/3.4.7/
      It says Python3.6 and newer, so latest works

    • @pedrodellazzari528
      @pedrodellazzari528 ปีที่แล้ว

      Did you get it to run with Undetected-chromedriver? I'm also trying to run in Lambda but I can't make it work at all

    • @mrsseeppoo
      @mrsseeppoo ปีที่แล้ว

      @@pedrodellazzari528 unfortunately no.

  • @spartan07-z4e
    @spartan07-z4e ปีที่แล้ว +1

    Hello Michael ,
    How to Making Captcha Breaking Script Work in AWS Lambda

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Same way you do it locally, I have made a video for bypassing captcha, check it out here: th-cam.com/video/5puz9Mb2d_c/w-d-xo.html

  • @pablorosa2960
    @pablorosa2960 ปีที่แล้ว +3

    i've been working with python 3.9 and i am struggle with this error : "Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127"
    Does anyone have any idea how to fix it? I have followed step by step very carefully

    • @khushindarshan156
      @khushindarshan156 ปีที่แล้ว +1

      same issue with me as well. Strugling with this from past few days and tried almost all the options available on internet. But still can't figure out. Did you got the solution??

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว +1

      AWS gives us the option to set up specific runtime for each lambda function. Use the same version as I said, and there shouldn't be an issue.

    • @VIKASSAINI007
      @VIKASSAINI007 10 หลายเดือนก่อน

      @@khushindarshan156 It is an version issue, it will only run on 3.7, any higher version will give 127 error

    • @leandrovillalobos6129
      @leandrovillalobos6129 9 หลายเดือนก่อน +1

      @@VIKASSAINI007 there's a way to make it work with 3.8 or later?, aws ends support for 3.7, so it can't be created anyways

  • @federicovazquezmorales4510
    @federicovazquezmorales4510 ปีที่แล้ว +2

    Thank you very much! It works!

  • @GANGSTA_CHUROOO
    @GANGSTA_CHUROOO ปีที่แล้ว +1

    using the commands provided, it downloads the chromedriver and the headless chromium but it doesnt open, it always says that the file format is not supported or is broken

    • @MichaelKitas
      @MichaelKitas  7 หลายเดือนก่อน

      Going to make an updated video today, stay tuned.

    • @mihirsabnis7240
      @mihirsabnis7240 6 หลายเดือนก่อน

      @@MichaelKitas Hey Michael, when can we expect the updated video?

  • @nolram1234
    @nolram1234 6 หลายเดือนก่อน +2

    Thanks so much, unfortunately python 3.7 isn't supported any longer. An updated video would be awesome!

    • @MichaelKitas
      @MichaelKitas  6 หลายเดือนก่อน +1

      Very soon, working on it, found a solution 👍

    • @mihirsabnis7240
      @mihirsabnis7240 6 หลายเดือนก่อน

      @@MichaelKitas How did you get past the error - Error setting up WebDriver: Message: disconnected: unable to connect to renderer? I am using a Docker image.

    • @MichaelKitas
      @MichaelKitas  3 หลายเดือนก่อน

      Just uploaded a new video which supports any python version: th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

    • @mihirsabnis7240
      @mihirsabnis7240 3 หลายเดือนก่อน +1

      @@MichaelKitas damn, thanks for following it up!

    • @nolram1234
      @nolram1234 3 หลายเดือนก่อน +1

      Thank you very much!

  • @benedictejelonu
    @benedictejelonu 3 หลายเดือนก่อน +1

    Hello Michael and everyone, does anyone have where I can find compatible versions for headless chrome and selenium that supports Python3.8?

    • @MichaelKitas
      @MichaelKitas  3 หลายเดือนก่อน +1

      Just uploaded a new video which supports any python version: th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

  • @coderlicious6565
    @coderlicious6565 ปีที่แล้ว +1

    Very informative.
    Do you know if there is a way to configure your AWS lambda account, to tell Amazon a max dollar amount you want to spend, and then if you accidentally exceed that amount with your resources, they either immediately notify you, or just simply shut down your site? I'd prefer it works that way.
    I'd hate to get a big surprise bill from amazon, because I didn't know my code was very inefficient, and the code was spending too much time during a function invocation.

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว +1

      Yes, check how to do that here: aws.amazon.com/getting-started/hands-on/control-your-costs-free-tier-budgets/

    • @coderlicious6565
      @coderlicious6565 ปีที่แล้ว

      @@MichaelKitas Thank you

  • @EstebanGarcíaPiñón
    @EstebanGarcíaPiñón ปีที่แล้ว +1

    Hey Mike! This can work with 'playwright'?

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Not sure, will add a series for playwright in the future, and try it

  • @diegotenorio7793
    @diegotenorio7793 ปีที่แล้ว +1

    I get the message below when putting it to test:
    {
    "errorMessage": "'module' object is not callable",
    "errorType": "TypeError",
    "stackTrace": [
    " File \"/var/runtime/bootstrap.py\", line 127, in handle_event_request
    response = request_handler(event, lambda_context)
    "
    ]
    }
    can you help me?

  • @ghoulflier1016
    @ghoulflier1016 2 ปีที่แล้ว +1

    Ok, so how can I know which version of Python, Selenium and Chromedriver works with Lambda?

    • @MichaelKitas
      @MichaelKitas  2 ปีที่แล้ว

      I showed on the video the versions I used

    • @ghoulflier1016
      @ghoulflier1016 2 ปีที่แล้ว +1

      @@MichaelKitas Yes, and only that version works for me. But how do I know when AWS supports newer versions and which combination of python, selenium and chromedriver? I don't want to operate with 3.7 forever.

    • @MichaelKitas
      @MichaelKitas  2 ปีที่แล้ว

      ​@@ghoulflier1016 Not sure, I don't think there is a specific combination each time

    • @ghoulflier1016
      @ghoulflier1016 2 ปีที่แล้ว +2

      @@MichaelKitas Thank you anyways for your great videos. They are such a big help for me to get started with Selenium!

  • @vicalomen
    @vicalomen 2 ปีที่แล้ว +1

    Do you know about this error "errorMessage": "Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127
    ",?

    • @vicalomen
      @vicalomen 2 ปีที่แล้ว

      Python version must be 3.7 and selenium 3.8.0

    • @MichaelKitas
      @MichaelKitas  2 ปีที่แล้ว

      Yes, first of all did you add chromedriver as a layer?

    • @celeb_life_in_30
      @celeb_life_in_30 ปีที่แล้ว

      I was also getting the same error when I was using latest selenium and chromedriver version.

  • @MichaelGavrilenko
    @MichaelGavrilenko ปีที่แล้ว

    Hello. Thank you for so necessary video. How could you upload the file more than 10Mb in the layer? (chromedriver.zip 44.6Mb) System should had to make you to upload through S3. Is not it?

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Yes, you can use S3, max is 50mb if not using s3

  • @elsavandenberghe4965
    @elsavandenberghe4965 2 ปีที่แล้ว

    Hi, I keep getting the error "no chrome binary at /var/taskheadless-chromium
    ". I added the selenium layer, connected it to the lambda function and installed the specific versions you had. Nothing is working to fix it.

    • @MichaelKitas
      @MichaelKitas  2 ปีที่แล้ว

      Did you add correct executable path? It’s searching in the wrong place

  • @CristóbalAbarca-j4b
    @CristóbalAbarca-j4b ปีที่แล้ว +1

    It works for me.
    does anyone knows if there is a way to do it in python3.9 or python3.8? i did not found a solution without the use of a 5xxmb approx docker image

    • @CristóbalAbarca-j4b
      @CristóbalAbarca-j4b ปีที่แล้ว +1

      My concern is because python3.7 is "deprecated" since june 2023, and if aws lambda does not support it anymore, we are done...

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      Looking for a solution and will make a video for newer version

    • @kapilbadokar
      @kapilbadokar 11 หลายเดือนก่อน

      @@CristóbalAbarca-j4b So if i want to do it now, Can't i do it with python 3.7 ? Please elaborate more . And if I have to use Python3.9/3.10 then What versions of chromedriver and headless chromium should i use?

    • @MichaelKitas
      @MichaelKitas  3 หลายเดือนก่อน

      Just uploaded a new video which supports any python version: th-cam.com/video/j_qOVqQDBWw/w-d-xo.html

  • @sudiptobose8522
    @sudiptobose8522 ปีที่แล้ว

    Does downloading the chromedriver on windows follows the same command?

    • @MichaelKitas
      @MichaelKitas  ปีที่แล้ว

      You can download chromedriver from the official website: chromedriver.chromium.org/downloads

    • @nekhumbecolbert2452
      @nekhumbecolbert2452 ปีที่แล้ว

      @@MichaelKitas for windows, do we also need to download the headless chromium like you did on the video or just a chrome driver downloaded from the site you mentioned above is okay?if yes, where do i download the headless chromium?

  • @Fx-Weevils
    @Fx-Weevils 2 ปีที่แล้ว

    Is it possible to teach how to create a website or blog traffic bot that uses VPS and sends requests from Virtual Private server 🙏🙏

    • @MichaelKitas
      @MichaelKitas  2 ปีที่แล้ว +1

      Very specific, but I might do that in the future, stay tuned!

  • @nimonaX
    @nimonaX 2 หลายเดือนก่อน

    can we run in aws glue

  • @LinykerVinicius
    @LinykerVinicius 6 หลายเดือนก่อน

    Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127
    :(

    • @zozoland9057
      @zozoland9057 6 หลายเดือนก่อน

      I had the same issue, and did not find anything that could solve it. Apparently a new tutorial is on the way!

    • @samiullah_991
      @samiullah_991 3 หลายเดือนก่อน

      @@zozoland9057 Hey bro, did you find the new tutorial video?

  • @kapilbadokar
    @kapilbadokar 11 หลายเดือนก่อน +1

    I have done exactly the same as shown in the video . But when i run I get this response .-> {
    "errorMessage": "Syntax error in module 'main': invalid syntax (selenium_manager.py, line 46)",
    "errorType": "Runtime.UserCodeSyntaxError",
    "stackTrace": [
    " File \"/opt/python/lib/python3.7/site-packages/selenium/webdriver/common/selenium_manager.py\" Line 46
    if (path := os.getenv(\"SE_MANAGER_PATH\")) is not None:
    "
    ]
    }

    • @MichaelKitas
      @MichaelKitas  7 หลายเดือนก่อน

      Going to make an updated video today, stay tuned.