I was wondering if this might be a compilation error or if there is something I can do to stop it from displaying. I have made an argparse program for cmd. I compiled it with py2exe and when I run it, it exacutes the program properly but always gives this error before running the code:
Traceback (most recent call last):
File "boot_common.py", line 46, in <module>
ImportError: No module named 'ctypes'
If it is something in my code, here is my script:
import argparse
import zipfile
import os
from contextlib import closing
def parse_args():
parser = argparse.ArgumentParser('ziputil '+\
'-m <mode> -f <file> -p <output>')
parser.add_argument('-f', action="store", dest='files', type=str,
help='-f <file> : Specify the files to be zipped, or the .zip to be unzipped.')
parser.add_argument('-m', action="store", dest='mode', type=str,
help='-m <mode> : Zip to zip files, UnZip, to unzip files, or ZipDir to zip entire directories.')
parser.add_argument('-p', action="store", dest='path', type=str, nargs='?', const=os.getcwd(),
help='-p <path> : specify the path to unpack/pack to.')
return vars(parser.parse_args())
def unzipPackage(path, files):
with zipfile.ZipFile(files, "r") as z:
z.extractall(path)
def zipPackage(path, files):
files = files.split(', ')
zf = zipfile.ZipFile(path, mode='w')
try:
for file in files:
zf.write(file)
finally:
zf.close()
def zipdir(path, zip):
for root, dirs, files in os.walk(path):
for file in files:
zip.write(os.path.join(root, file))
dict = parse_args()
files = dict['files']
path = dict['path']
mode = dict['mode']
if mode == 'Zip':
zipPackage(path, files)
elif mode == 'UnZip':
unzipPackage(path, files)
elif mode == 'ZipDir':
zipf = zipfile.ZipFile(path, 'w')
zipdir(files, zipf)
zipf.close()