Markins
Markins

Reputation: 23

Trying to convert to exe from the py file

I am trying to convert the py file to exe file but after conversion I have successfully converted the py to exe .But on clicking on the exe file the terminal just closes and open and nothing happens. My script displays a notification with a new word and its meaning everyday when I run on the ide(Pycharm) but after the conversion to exe using auto-py-to-exe nothing is happening.I have also tried by importing the missing modules

import urllib.request  # used to send requests basically https requests
from bs4 import BeautifulSoup  # used to parse xml and html pages so that we can extract data from webpages. It
# creates a parse tree for webpages
import time
from plyer import notification

if __name__ == '__main__':
    url = "https://www.dictionary.com/e/word-of-the-day/"  # any url can be inserted here as u wish
    html_file = urllib.request.urlopen(url)
    soup = BeautifulSoup(html_file, 'lxml')  # for documentation check this https://zetcode.com/python/beautifulsoup/

    soup1 = soup.find(class_="otd-item-headword__word")  # inspect the page and find the specific data to crawl the
    # data from the html code

    try:
        soup1 = soup1.get_text()
    except AttributeError:
        print('No words for today. You have learnt enough')
        exit()

    txt10 = soup1.rstrip()  # The rstrip() method returns a copy of the string by removing the trailing characters
    # specified as argument.
    soup2 = soup.find(class_="otd-item-headword__pos")
    soup2 = soup2.get_text()
    txt11 = soup2.rstrip()
    soup3 = soup.find(class_="wotd-item-origin__content wotd-item-origin__content-full")
    txt = soup3.get_text()
    txt1 = txt.rstrip()

    notification.notify(
        title="*** WORD OF THE DAY ***" + "\n" + ' '.join(txt10.split()) + "\n",
        message="MEANING:" + ' '.join(txt11.split()),
        # app_icon=r"C:\Users\HP\PycharmProjects\MyProjects\book.ico",
        app_icon=r"C:\Users\purba\PycharmProjects\pythonProject\dictionary.ico",
        ticker=r"Vocab APP",
        app_name=r"PYTHON PROJECT: VOCAB APP 365",
        timeout=60
    )
    time.sleep(60 * 60)

Upvotes: 0

Views: 669

Answers (3)

Ehsan Rahi
Ehsan Rahi

Reputation: 71

Follow these step or watch this YouTube tutorial:

  • Install pip install pyinstaller module in python.

  • Go to your python installed directories. and open command prompt then install pyinstaller

  • After open command prompt and type "pyinstaller --onefile -w then your file path or name

Upvotes: 0

CCCC
CCCC

Reputation: 251

         pip uninstall typing

That should fix it. Thereafter run your pyinstaller code, your exe file will be created and when you run it, it won't crash.

Upvotes: 0

Nora
Nora

Reputation: 161

This is normal behavior. The python script will exit immediately after it completed its job. To make your application hang before closing, you can add this code at the end of your script:

input("Press any key to exit...") 

Upvotes: 1

Related Questions