Random long load time (15min) for exe in Prompt [windows/anaconda]

34 views
Skip to first unread message

Siwen L

unread,
Mar 17, 2021, 4:11:54 AM3/17/21
to PyInstaller
Dear Pyinstaller,
I have packaged the py into and exe file via pyinstaller -F.
It was working fine [-running exe] till last July with windows prompt. However windows prompt is unable to run it anymore, but the Anaconda prompt managed to deliver the same output.
The script works fine in Jyputer notebook but having different loading time in anaconda prompt, sometimes it's 15min, and sometimes it's 1min and sometimes takes hours to load the first line.
I have run it with the latest pyinstaller version V4.2.
Wondering anyone has similiar issue? and how can I resolve it?
Thanks ahead!

Siwen L

unread,
Mar 17, 2021, 7:37:07 AM3/17/21
to PyInstaller
Attached is the shorten script that facing difficulties.



import time
startTime = time.time()
print("8")
import pandas as pd
import numpy as np
print("9")
import datetime as dt  
#import sys
import os
print("10")
import errno
from pathlib import Path
print("11")
import math

print("1")
path_input = input ("Enter the path of your file: ")
print("2")
in_data_folder = Path(path_input)
print("3")
file_input = input ("Enter the name of your file: ")
print("4")
in_path = in_data_folder / file_input
print("5")
zmm_raw = pd.read_csv(in_path)
print("6")


exclusion_path = input ("Enter the path of exlcusion file: ")
zmm_exlu = Path(exclusion_path + '/ rules .xlsx')
zmm_exclusion = pd.ExcelFile(zmm_exlu)


#define time
today = dt.datetime.today().strftime("%Y-%m-%d")
fileNameToday = dt.datetime.today().strftime("%d%m%y")

file_output = "/"+fileNameToday + "_"+ file_input[0:len(file_input)-4] + "_temp_action_output" 
out_path = path_input + file_output +"//"
if not os.path.exists(os.path.dirname(out_path)):
    try:
        os.makedirs(os.path.dirname(out_path))
    except OSError as exc: # Guard against race conditions
        if exc.errno != errno.EEXIST:
            raise

print('File reading is completed')

Siwen L

unread,
Mar 17, 2021, 7:37:26 AM3/17/21
to PyInstaller
The script freeze like this after 1/2 successful runs. Is there any things need to clear after certain run? hang.png

On Wednesday, March 17, 2021 at 4:11:54 PM UTC+8 Siwen L wrote:

bwoodsend

unread,
Mar 18, 2021, 8:46:29 AM3/18/21
to PyInstaller

Initialization delays are caused by your antivirus scanning each binary as it's loaded in. Conda's distribution of NumPy  contains 500MB of binaries so can take ages to scan. Your options are:

  • Don't use onefile mode. This way it'll be scanned the first time you run but never again (unless you compile again).
  • Use regular NumPy from PyPI. This is only 30MB so takes just a few seconds.
  • Turn off your antivirus.
Personally I'd recommend you do all three.

Siwen L

unread,
Mar 19, 2021, 6:56:25 AM3/19/21
to PyInstaller
Hi Bwoodsend,
Thanks for your reply,
  • Don't use onefile mode. This way it'll be scanned the first time you run but never again (unless you compile again).
    • the script will quit in Onedir mode w/o any output as exe from onefile mode after the run is complete 
  • Use regular NumPy from PyPI. This is only 30MB so takes just a few seconds.
    • I have sized down the exe from 500MB to 28MB, but the same issue remains. The script will freeze from every second run onwrads
  • Turn off your antivirus.
    • unable to do so, also don't think it's the anrivirus scan since the freezing duration is the same comparign to 500MB to 28MB.
Is there any other possible reasons for it?
Thanks 

Siwen L

unread,
Mar 22, 2021, 3:53:13 AM3/22/21
to PyInstaller
Just to add on, after trying all the methods, the script freeze before import time.
T_T

Reply all
Reply to author
Forward
0 new messages