Incorrect operation .exe file with pyinstaller

Question:

I have a piece of code that is given below. When opening the .exe db is created and after that the program goes into an endless loop, trying to create more files and outputs an error that the products table already exists. Moreover, if you run the code using pycharm, everything works fine.

if __name__ == '__main__':
    now = datetime.now()
    time_now = now.strftime("%H %M")
    file_name = r'data/result1 ' + (str(date.today())) + ' ' + time_now + '.db'
    ittr = 0
    conn = sqlite3.connect(file_name)
    cursor = conn.cursor()
    cursor.execute("""CREATE TABLE "products" (
                "категория" TEXT NOT NULL,
                "производитель" TEXT NOT NULL,
                "название"  TEXT NOT NULL,
                "цена"  TEXT NOT NULL,
                "продажи"   INTEGER NOT NULL,
                "наличие"   TEXT NOT NULL,
                "рейтинг"   TEXT NOT NULL,
                "отзывы"    TEXT NOT NULL,
                "айди"  TEXT NOT NULL
            );
                           """)
    conn.commit()
    with multiprocessing.Pool(1) as p:
        for i in range(190):
            start_id = 1 + 10000 * ittr
            end_id = 10000 + 10000 * ittr
            ittr = ittr + 1
            p.apply_async(main, args=(start_id,end_id, ), callback=data_processing)
        p.close()
        p.join()
Asked By: ZINA312

||

Answers:

I found on the wiki that you need to immediately after if __name__ == '__main__': write multiprocessing.freeze_support() and everything worked!
For more information visit https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support

Answered By: ZINA312
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.