-2

I have created a code that automates some kind of task using python. So for that I imported a module named Pywhatkit. But after importing when I run the program first I get this(shown in the attached image below) note from creator of Pywhatkit(highlighted part in the attachment below)and then I am able to run my program. Sometimes this seems unprofessional. So is there any way too either change the name that appears on running the program or is there any way with which I can remove this part?enter image description here

2 Answers2

1

Python modules are generally written in python. If you need to make a modification like this, you can usually just look up where the module is installed and change the relevant bit of the code (usually in your python version's site_modules directory, in a folder named the same as the module, where the file __init__.py is the first thing executed, so that's a good place to start if you're blindly searching for something to change).

In this particular case, do the following:

  1. Run the console command pip show pywhatkit to find the location of the installed pywhatkit module. Should be the third-to-last line of that command's output. I'll call this $pwkdir
  2. Open the file $pwkdir/pywhatkit/mainfunctions.py in your text editor of choice
  3. Comment out lines 300 through 304, and save the file.
    • the cause of the output you're seeing is a straightforward print() call, so removing it is easy and harmless.

I found the location that needs to be commented out by doing the command grep -nr 'Hello from the' $pwkdir/pywhatkit (i.e. searching for any usages of the observed phrase, because the first three words are enough to identify it), and reading the code.

You will probably need to do this again every time you reinstall or update this module to a new version.


Note that there are other places within the module where it prints to console. You may wish to search for and comment out those lines as well, or disable printing to stdout before importing the module for the first time.

Green Cloak Guy
  • 23,793
  • 4
  • 33
  • 53
1

Noted, this "Note from the creator" will be removed from the next update. Meanwhile, you can do as suggested in the other answer, you may consider editing the "mainfunctions.py", commenting the last print statement of that file will stop printing the message.