r/CodingHelp - Python : Code Not Working

Please help . I am starting to code and this is not working .

Code :

from plyer import notification

def notifyMe (title,message):
    notification.notify(
    title = title,
    message = message,
    app_icon = None,
    timeout = 10
    name = None,
    )
if name== ("main"):
    notifyMe ("Palash","Lets stop the spread of this virus")


Terminal

PS E:\WhiteHat JR\Hackathon\TryOne - Notification> pip install plyer
Collecting plyer
Downloading plyer-1.4.3-py2.py3-none-any.whl (133 kB)
ication> python main.py
PS E:\WhiteHat JR\Hackathon\TryOne - Notification> python main.py
if name== (“main”):
NameError: name ‘name’ is not defined

What the library plyer It’s supposed to do? I ran it on IDLE and, despite It didn’t throw any error, I didn’t have any kind of feedback either.

from plyer import notification

def notifyMe (title,message):
    notification.notify(
    title = title,
    message = message,
    app_icon = None,
    timeout = 10,
    name= None)
    if name == ("main"):
        notifyMe ("Palash","Lets stop the spread of this virus")

But i the notification did not pop up

i am using this tutorial

Try this change, variable name and string requires underscores. Also, If u are on windows 10 or lower. You need to install
winnotify

from plyer import notification

def notifyMe (title,message):
    notification.notify(
    title = title,
    message = message,
    app_icon = None,
    timeout = 10)
    
if __name__ == ("__main__"):
    notifyMe ("Palash","Lets stop the spread of this virus")


1 Like

Welcome, PalPalash.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Please see the above post. (because i cannot format it over here)

--------------------------------PASTES----------------------------------------
Paste Bin 1 : https://pastebin.com/RbEuXAc8
Others in reply

Paste Bin 2 : https://pastebin.com/vk35RdQV (Full code)

Paste Bin 3 : https://pastebin.com/wfpzfnD6

Hi Palash,

nice to meet you! :wave:

Another user posted a solution how to format code:

Please do not create multiple topics and do not crosspost over different platforms, because this decreases the experience of people who want to help.


Regarding your errors:

Do all packages show up as installed on your system?
Which versions show up?

1 Like