pyinstaller works on one pc but not on another

36 views
Skip to first unread message

Rafael Castelo Branco F. Costa

unread,
Apr 16, 2020, 10:05:14 AM4/16/20
to PyInstaller
Recently I created a python script to read some excel files and create a new Pandas DataFrame from such readings. I created an executable file through Pyinstaller (onefile and multiple files). If I run the code on my interpreter it goes perfectly, if I run the executable on my PC it also works but if my colleague runs on her computer, it gets the error displayed on the attached image.


This is the second error the executable threw. First I got an error importing 'pkg_resources.py2_warn' which I corrected following Pyinstaller instruction to import the package directly on the code, but for this Error -3 I could find nothing.

Does anyone know how to solve this issue? The full code is below.


Thanks!

###Import Libraries
import os
import pandas as pd
import pkg_resources.py2_warn

###Variables
CAO, CAO2, F24, F26, F25, F28, S48, S49, S50, S76, S77, S78, T51, T68,T79, T86, T83, multiplication, Sum_EF, Sum_EG, lst, file_list, indx = [],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]
temp = pd.DataFrame()
path = r'C:\Users\Documents\Codes\test'

###Setting the file list
f_list = os.listdir(path)
for l in f_list:
    try:
      c = l.split('_')[1]  
      if c[0] != 'C':
          file_list.append(l)
    except: None

###Data mining
for file in file_list:
    cao = int(file.split('_')[1])  
    file_path = os.path.join(path, file)
    f = pd.read_excel(file_path, sheet_name = 'CAO - Recap', header = 21, usecols = 'F, S, T')
    f24 = f.iloc[1][0]
    f25 = f.iloc[2][0]
    f26 = f.iloc[3][0]
    f28 = f.iloc[5][0]
    s48 = f.iloc[25][1]
    s49 = f.iloc[26][1]
    s50 = f.iloc[27][1]
    s76 = f.iloc[53][1]
    s77 = f.iloc[54][1]
    s78 = f.iloc[55][1]
    t51 = f.iloc[28][2]
    t68 = f.iloc[45][2]
    t79 = f.iloc[56][2]
    t86 = f.iloc[63][2]
    t83 = f.iloc[60][2]         
    mult = t86 * t83 * 0.002

    CAO.append(cao)
    F24.append(f24)
    F25.append(f25)
    F26.append(f26)
    F28.append(f28) 
    S48.append(s48) 
    S49.append(s49) 
    S50.append(s50)
    S76.append(s76)
    S77.append(s77)
    S78.append(s78)
    T51.append(t51)
    T68.append(t68)
    T79.append(t79)
    T83.append(t83)
    T86.append(t86)
    multiplication.append(mult)

###DataFrame assembly
temp['CAO'] = pd.Series(CAO)
temp['F24'] = pd.Series(F24) 
temp['F25'] = pd.Series(F25)     
temp['F26'] = pd.Series(F26)
temp['F28'] = pd.Series(F28)
temp['S48'] = pd.Series(S48)
temp['S49'] = pd.Series(S49)      
temp['S50'] = pd.Series(S50)
temp['S76'] = pd.Series(S76)
temp['S77'] = pd.Series(S77)         
temp['S78'] = pd.Series(S78)
temp['T51'] = pd.Series(T51)
temp['T68'] = pd.Series(T68)
temp['T79'] = pd.Series(T79)
temp['T83'] = pd.Series(T83)
temp['T86'] = pd.Series(T86)
temp['Multiplication'] = pd.Series(multiplication)

###Data Cleaning
temp = temp.loc[: , ~temp.columns.str.contains('^Unnamed')]
temp.reset_index()

###Data Structure auxiliary table
order = pd.DataFrame(columns = {'index', 'CAO'}) ##Ordering rows
order['CAO'] = pd.Series([2948, 533, 487, 433, 10, 1612, 301, 1496, 1869, 1944, 234, 50, 833, 496, 725, 1287, 3798, 243, 750, 748, 3768, 650, 3854, 2535, 637, 26, 51, 41, 791, 359, 35, 157, 465, 254, 214, 615, 1945, 2266, 549, 245, 83, 1537, 848, 573, 306, 279, 632, 979, 253, 1393, 475, 709, 171, 118, 125, 1029, 563, 1193, 187, 1841, 819, 841, 2674, 152, 80, 310, 1438, 227, 2872, 506, 645, 776, 85, 636, 3954, 3233, 1228, 3967, 830])

n = 1
for i in order['CAO']:
    indx.append(n)
    n += 1

order['index'] = pd.Series(indx)

###DataFrame preparation
Lst1 = pd.merge(order, temp, on = 'CAO', how = 'left' )
Lst1.drop_duplicates(subset = 'index', keep = 'first')
Lst1.reset_index()
Lst1 = Lst1[['CAO', 'T68', 'T86', 'T83', 'Multiplication', 'T79', 'S76', 'S77', 'S78', 'F24', 'F26', 'F25', 'F28', 'T51', 'S48', 'S49', 'S50']] ##Ordering columns 'Sum_EF', 'Sum_EG'
Lst1 = Lst1.fillna('-')

Lst1.to_csv(r'C:\Users\Documents\full_list.csv', sep = ';', decimal = ',')
error.png

bwoodsend

unread,
Apr 16, 2020, 2:10:20 PM4/16/20
to PyInstaller
Could you put a print statement before and after each import. i.e
print("Importing os")
import os
print("Importing pandas")
import pandas as pd
print("Importing package_resources")
import pkg_resources.py2_warn
print("Imported all")

I strongly suspect one of pandas non mandatory imports which you don't need is being bundled and loaded. As far as I know, your code shouldn't be going anywhere near Cython. So it should be a case of passing some --exclude-module arguments. Ideally you should create a clean environment and only install what you know you need but you don't have to. I'd start by giving it `--exclude-module Cython`.

Brénainn

Steve Barnes

unread,
Apr 17, 2020, 10:11:54 AM4/17/20
to pyins...@googlegroups.com

Hi,

 

You are creating you package with Python 3.7 64 Bit – is the other computer Windows 32 by any chance?

 

Steve

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/bf7f69e5-cea3-436f-b98a-c3a60b49b64a%40googlegroups.com.

Dan Campbell

unread,
Apr 17, 2020, 1:58:25 PM4/17/20
to pyins...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages