4

I'm quite new to python and programming in general, so don't judge too strict=)

I'm trying to convert my .py file into .exe using py2exe. I use pandas in my code. My code successfully (at least it seems to be successful) converts to a folder with a bunch of files, among which .exe is presented. But when I launch my .exe file from dist folder, command prompt throughs an error "no module named pandas". Seems like such .exe doesn't work with external libraries.

How can I make it work? to accept pandas or other external libraries... And also to make a GUI for it.

My code for converting to exe is the simplest (not sure if it's correct for this case):

from distutils.core import setup
import py2exe`
setup(console=['test_append.py'])

and the program itself:

import os
import pandas as pd
import zipfile as zf

s=[]
x=raw_input('Enter path where archives lay:')
for i in x:
    s.append(i)
if s[len(s)-1]=='\\':
    s.pop(len(s)-1)
x=''.join(s)


def append_arch(n):
    saved_path=os.getcwd()
    os.chdir(n)
    filenames=os.listdir(n)
    m1=zf.ZipFile(n+'\\'+filenames[0])
    arch_files1=m1.namelist()
    m1.extract(arch_files1[0],n+'\z-extraction')
    main_csv=pd.read_csv(n+'\z-extraction\\'+arch_files1[0],';')
    main_df=pd.DataFrame(main_csv)
    try:
        for i in filenames[1:]:   #[1:len(filenames)-1]
            m=zf.ZipFile(n+'\\'+i)
            arch_files=m.namelist()
            print i            
            print arch_files[0]

            m.extract(arch_files[0],n+'\z-extraction')
            next_csv=pd.read_csv(n+'\z-extraction\\'+arch_files[0],';')
            next_df=pd.DataFrame(next_csv)
            main_df=main_df.append(next_df)
            print main_df.tail()
            os.remove(n+'\z-extraction\\'+arch_files[0])
        main_df.to_csv(n+'\z-extraction\\'+'appended.csv', index=False)
    except:
        print 'error in object '+i
    print main_df.info()
    print 'Done'


append_arch(x)
Thanos
  • 2,472
  • 1
  • 16
  • 33
Dmitriy Fialkovskiy
  • 3,065
  • 8
  • 32
  • 47
  • already tried - didn't help. If to add "import pandas" to setup.py, command prompt throughs same error but before converting to exe. – Dmitriy Fialkovskiy Feb 26 '16 at 09:20
  • Possible duplicate of [py2exe "include" modules: when should they be managed manually?](http://stackoverflow.com/questions/10098444/py2exe-include-modules-when-should-they-be-managed-manually) – Peter Wood Feb 26 '16 at 09:24
  • I played with py2exe and pandas in the past, definitely moved to either nuitka or pyinstaller. – fernandezcuesta Feb 26 '16 at 09:24

0 Answers0