Screencast Build a Python Weather Forecast Mailer Python

  • Sarah Holderness
  • 9541 views

Comments

  1. Daniela Becerra said

    I'm following along on my computer doing the project, and I tried to send the email using my account information, apparently, Gmail blocks the attempt to login because it's unsafe, how did you do it? I tried using flyingthroughpython's credentials, but you already seemed to changed the password, lol. I just want to practice... but I don't want to leave my account vulnerable.

  2. Andyandpandy said

    This took alot longer than it should have in my opinion. Nevertheless it was a nice screencast and learning a bit about the possibilities with python besides fooling around with exercises was great!

  3. Rafael Santos said

    Is it in the plans to evolve the python path into a backend dev?

  4. Faculty

    Sarah Holderness said

    Daniela, we realized that we forgot a step in configuring the Gmail account to work the right way for this example. If you create a brand new account it's not a problem, but if you're using an existing account, you'll first have to navigate to Gmail->My Account->Signing in to Google->Allow less secure apps and set that setting to ON. If you leave that setting as OFF you have to do some extra authentication stuff that takes a little longer to set up, and we didn't want to include that in this video for the purposes of this demo (Look at app-specific passwords if you're interested). If there's any other questions you can post in our forum http://discuss.codeschool.io/c/screencasts/soup-to-bits and get help there!

  5. Faculty

    Sarah Holderness said

    Rafael, we are working on more Python courses that will include backend dev.

  6. Don Glover said

    Not possible to download this video?

  7. Priyam Sarma said

    When is it appropriate to keep the try..exception blocks in your code? Is it just for initial unit testing or would it exist in prod code? For example when you finalized your weather module, would we keep the try...exception blocks or not?

  8. Daniela Becerra said

    thank you Sarah! I'll try again later in this week. :)

  9. kernelfred said

    Great video! At first I thought you would have wanted to edit the video so some of the minor goofs (typos and such) were removed, but I'm glad you kept them in. Not only did it provide an impromptu opportunity to show some of the pitfalls when writing code, but it also kept the tone light! Big fan of the Python series, really hope you guys make more videos. Keep up the good work! (PS - maybe you can add a caption mentioning the authentication issue with Gmail with 'insecure' apps?)

  10. Joshua Dickey said

    Great job! I loved this tutorial. Easy to follow instructions.

  11. Mark Fletcher said

    Enjoyed watching this video. Looking forward to more Python courses and screencasts in future. Thanks!

  12. coeibu said

    many thanks!

  13. andrefurquim said

    I like the pace of the instructor! It's was a lot easier for me to follow than the other casts! :)

  14. andrefurquim said

    I suggest a Django course now.. :D

  15. Fazle Arefin said

    Nicely presented. Thank you!

  16. peacengell said

    Yes a django course now. thanks for this lovely video tutorials so nice so easy to understand. make more if you can please this help newbies a lot..

  17. kruasanova said

    awesome! thanks!

  18. Himanshu Virkar said

    Video was really useful to get started with a real example of Python. The video could have been a bit short if the "conversational" bit was left out, but nonetheless it was a very useful and practical session. Also, leaving out the various errors in it told us that we all should be cognitive of such coding errors. PS: Sara, please stop talking like a cat growling. It is very unpleasant on the ears! Sorry, but its true.

  19. Colin said

    Fantastic series so far. Would love to see more like this and in the same style. The Python course set-up and this video has been just what I needed to break back into coding. Last time was in the 80's! I appreciate your good work.

  20. TheCOLTRANE said

    Great walk through. The 'oops' add to the approach-ability when trying to learn! A pedantic point, on the weather API: the min / max for weather are within the city. If you want Hi/Low you need to query Forecast: "Please, do not confuse min/max parameters in current weather API and forecast API. In current weather API temp_min and temp_max are optional parameters mean min / max temperature in the city at the current moment to see deviation from current temp just for your reference. For large cities and megalopolises geographically expanded it might be applicable. In most cases both temp_min and temp_max parameters have the same volume as 'temp'. Please, use temp_min and temp_max parameters in current weather API optionally."

  21. Richik Haldar said

    I am trying to use a tuple in the first function: get_emails() but it keeps saying "not enough values to unpack (expected 2, got 1) {}. What is going on here?

  22. Eduardo said

    Great course.. thanks guys! I am looking forward the Backend dev track!

  23. Stuligan said

    This was awesome! Thanks!

  24. Alban Boitier said

    Fantastic class, thank you guys. Just a thing: could you create a document easily downloadable with all the functions/commands we saw in the class as a reminder? Keep up the good work!

  25. HECTOR said

    Great course and great screencast If anyone helps I used this to get the password

    import getpass password = getpass.getpass("What's your password? ")

    So the console won't show the password, like when you use sudo or su

  26. Haiyang Yu said

    Thanks to this video I managed to jump head start into python programming!

    I have been dragging this for more than 1 year and now you have shown my how simple it is to start programming in python and using standard and non-standard packages.

    But 1 major challenge I faced was to install non-standard package, i.e. requests. My MacBook has python 2.7 pre-installed. I installed homebrew to install pip and used pip to install requests. But when I tried to import requests in IDLE shell it prompted that requests cannot be found.

    After a lot of searching and trial I realised that I should use python3.5 alias to import requests in Terminal which did the trick...

    Hope you have this info available for complete beginners to Mac and python like me. But if you actually have put it somewhere and I had missed, then please ignore this...

    All in all, thanks for the cast!

  27. Délita Makanda said

    Great tutorial !

  28. nicholson2208 said

    Hey guys, great video!

    For reference, I am using Python 3.5.1 on Windows. I ran into a weird issue while following along right around the 25:00 mark and I was hoping that someone could point out what I'm doing incorrectly.

    When I try to run my script, I get "ImportError: No module named 'requests'", even though the first line of my script is import requests but when I check in the Command Prompt by entering import requests, it seems to be working fine.

    I tried entering the relevant lines of code into the Command Prompt one and a time, and it works, but it doesn't work in my script.

    Anyone have any idea?

  29. nicholson2208 said

    Just kidding, I fixed it! Thanks!

  30. Stephen Calnan said

    Minor clarification on SSL/TLS in the e-mail configuration section. This doesn't encrypt your email, it encrypts the connection to the gmail server. If the recipient account is on a non-SSL/TLS server, gmail will forward it in the open.

  31. Jsthegr8 said

    This was fun and practical Thanks!, more Python Screencasts please :)

  32. Phu Phan said

    Nice :D

  33. Manu Ah said

    AWESOME video! Thank you Sarah! I always wanted to learn to use python and all of the courses helped amazingly to start this path. I never thought it could be used to develop email automation. Great work.

  34. Onchangu said

    Cool!

  35. MarWildCoder said

    Really well explained the whole course and ScreenCast, it seems easy when learning this way, so clear and entertaining...Great job and thanks!!

    I had just one doubt during the Screencast, when using this code:


    def get_schedule(): try: schedule_file = open('schedule.txt' , 'r') schedule = schedule_file.read() except FileNotFoundError as err: print(err)
    return schedule


    If the .txt file didn't exist, the program crashes even I am using try and except, the message I get in the Python shell reads:


    UnboundLocalError: local variable 'schedule' referenced before assignment

  36. Faculty

    Sarah Holderness said

    Hi @MarWildCoder - Since schedule is defined inside your try block, if you try to return schedule outside of that block the interpreter doesn't know about it. You can return it inside your try block instead, or define it as an empty string outside of the try block, either would work:

    def get_schedule(): schedule = '' try: schedule_file = open('schedule.txt' , 'r') schedule = schedule_file.read() except FileNotFoundError as err: print(err)

    return schedule

    Hope that helps! Thanks for watching :D

  37. MarWildCoder said

    It worked, thanks!

  38. TerrenceR87 said

    @SarahHolderness ,

    Great walkthrough! :) But I'm having trouble importing the requests module.

    Requests is available and works just fine when main.py is in a folder I'll call 'Parent.' Inside 'Parent' is also where I have pip, python, etc. installed.

    But, when I place my whole project into a subfolder of 'Parent' and run main.py, I get "ImportError: no module named 'requests'."

    Any idea what is going on here?

  39. TerrenceR87 said

    I managed to solve my problem.

    First, I uninstalled Python and the Python Launcher.

    When I went to reinstall Python, there is a checkbox at the bottom of the page that asks if you'd like to append Python to PATH. After googling and stackoverflowing for a day, it turns out that appending it to PATH allows us to access it across our machine.

    :)

  40. ShayleeHansen said

    I really enjoyed this video. Nice to have a practical example to look at and follow along with. Maybe one day I will get a mailing list going with my website :)

  41. MarkMad said

    I'm no expert but aren't you supposed to close the files after you've finished reading them? Also, I was cringing that during the testing, the emails were being sent to the whole mailing list. Thankfully, it wasn't a "real" mailing list, but since you previously tested it by sending it to yourself, you should have kept that until the final run where you replace it with a mailing list.

  42. Rafał Grzejszczyk said

    Sarah, I love you!

  43. binhpht said

    Sarah, im a big fan of you

  44. Rishit Gupta said

    Sarah, can you please help me? When I run the scripts, it says this- Traceback (most recent call last): File "C:\Users\rishitgupta\Documents\RG\HTML\Weather Mailer\emailer.py", line 37, in main() File "C:\Users\rishitgupta\Documents\RG\HTML\Weather Mailer\emailer.py", line 34, in main smtp.send_emails(emails, forecast) File "C:\Users\rishitgupta\Documents\RG\HTML\Weather Mailer\smtp.py", line 13, in send_emails server.login(from_email, password) File "C:\Users\rishitgupta\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py", line 729, in login raise last_exception File "C:\Users\rishitgupta\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py", line 720, in login initial_response_ok=initial_response_ok) File "C:\Users\rishitgupta\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py", line 641, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, b'5.7.14 Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 g82sm19242858pfb.43 - gsmtp')

    Please help me! Thanks

  45. Rishit Gupta said

    @SarahHolderness , can you please help me? When I run the scripts, it says this-

    Traceback (most recent call last): File "C:\Users\rishitgupta\Documents\RG\HTML\Weather Mailer\emailer.py", line 37, in main() File "C:\Users\rishitgupta\Documents\RG\HTML\Weather Mailer\emailer.py", line 34, in main smtp.send_emails(emails, forecast) File "C:\Users\rishitgupta\Documents\RG\HTML\Weather Mailer\smtp.py", line 13, in send_emails server.login(from_email, password) File "C:\Users\rishitgupta\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py", line 729, in login raise last_exception File "C:\Users\rishitgupta\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py", line 720, in login initial_response_ok=initial_response_ok) File "C:\Users\rishitgupta\AppData\Local\Programs\Python\Python35-32\lib\smtplib.py", line 641, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, b'5.7.14 Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 g82sm19242858pfb.43 - gsmtp')

    Please help me! Thanks

  46. Camilo Riviere said

    Great Screencast!

  47. Camilo Riviere said

    Great Screencast!

  48. appleTACO said

    @Rishit Gupta you need to login to the gmail account that you are using to for this project (https://www.google.com/settings/security/lesssecureapps) and turn on 'Access for less secure apps'

    After that, re-run your script and see if that helps. I would recommend not using your actual gmail account for this project butinstead, just setup a new one so you can do the 'Access for less secure apps' instead of creating a password for this project/app.

    Hope this helped!

  49. Ildar Gabitov said

    Nice follow to do video...

  50. kishore28m said

    Nice screencast. Instead of using less secure apps method, I ended up using 2 step authentication.

  51. Brian Lash said

    The Python courses provided the perfect jumping off point for this walkthrough. Really nicely done.

  52. Nikhil Pereira said

    Yay! It works for me! Thank you for this tutorial!

  53. Alexey said

    Lovely course and handsome video!

  54. hemanth_s said

    where we need to keep those text files anywhere or in a particular directory? I am getting an error "file doesn't exist" but I had this email.txt file on my desktop. What is solution for this?

  55. Abhishek Vaid said

    Hello, I am using version 3.6.1 on Mac with idle. I cant seem to install the requests module on my system , I have tried using python documentation steps but it shows an error on 'pip' command. Could you please clarify what I need to do ?

  56. steveshead said

    Hi Abhishek - you need to install pip3 for Python 3 - I use brew so "brew install pip3" worked for me.

  57. steveshead said

    Actually - scratch that - pip3 is installed with Python 3 - try using "pip3 install requests" instead - sorry about that!

  58. Faculty

    Sarah Holderness said

    @hemanth_s, the text file should be in the same directory as your Python program. Or you can add the path to your text file in your Python program. Hope that helps!

  59. Tim Zuppa said

    Thanks Sarah, great practical

  60. masteruan said

    Great!!

  61. msashley018 said

    This is like the best segway into a screencast that I've watched so far! Thank you xoxo!

  62. akshayrawat95 said

    Hey there! I'm getting this error:

    Traceback (most recent call last): File "/Users/akshayrawat/Desktop/emailer.py", line 87, in main() File "/Users/akshayrawat/Desktop/emailer.py", line 85, in main send_emails(emails, schedule, forecast) File "/Users/akshayrawat/Desktop/emailer.py", line 71, in send_emails server.sendmail(from_email, to_email, message) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/smtplib.py", line 854, in sendmail msg = _fix_eols(msg).encode('ascii') UnicodeEncodeError: 'ascii' codec can't encode character '\xba' in position 164: ordinal not in range(128)

    Can anyone help me? It worked when I sent a test email to myself but gave me this error when I substituted the third field in the following line of code: server.sendmail(from_email, to_email, message)

  63. akshayrawat95 said

    Never mind. Figured it out. I put in the degree symbol (º) in the forecast and message doesn't support that character

  64. szachimat said

    It works! Great! :D

  65. btdroyale246 said

    What do you do if you have Windows/PC?

About This Screencast

In this episode, Sarah Holderness and James Newton will build upon what was taught in both the Try Python and Flying Through Python courses. We will demonstrate how to get Python set up, and then build a project together step by step.

You need to be an enrolled student in order to view this video and subscribe.

Enroll Now