I have written a python script in python 2.7 and I am facing a problem after exe conversion of this file using py2exe package. I have got the exe file but when i run, i got an error which i have mentioned below. Please note that I have saved the script file with name test.py. Please tell me the problem @Bryan Oakley
from Tkinter import *
import os
from os.path import expanduser
import time
import datetime
from docx import Document
from docx.shared import Inches
document = Document()
docx_prefix = "Doc_File_"
home_directory = expanduser("~")
folder_directory = home_directory + "\myapp"
doc_file_directory = folder_directory + "/"
if not os.path.exists(folder_directory):
os.makedirs(folder_directory)
def create_file():
now = datetime.datetime.now()
current_time = now.strftime("%Y-%m-%d %H%M%S")
file_name = docx_prefix + current_time
document = Document()
document.add_paragraph("word document")
document.save(doc_file_directory + file_name + '.docx')
main_root = Tk()
main_root.title("Toolbar")
main_root.geometry('105x26+1+1')
toolbar = Frame(main_root, bg="gray")
toolbar.pack(side="top")
create_file_button = Button(toolbar, text="Create File", command =
create_file, bg="gray", width=10)
create_file_button.pack(side="left")
main_root.mainloop()
Setup file for exe conversion using py2exe :
from distutils.core import setup
import py2exe
setup(
console=['test.py'],
options = {'py2exe': {'packages' : ['docx']}}
)
I am getting the following error after exe conversion:
C:\Python27\Lib\site-packages\py2exe\samples\scripting\dist>test.exe
Traceback (most recent call last):
File "test.py", line 6, in <module>
File "docx\__init__.pyc", line 3, in <module>
File "docx\api.pyc", line 14, in <module>
File "docx\package.pyc", line 11, in <module>
File "docx\opc\package.pyc", line 12, in <module>
File "docx\opc\part.pyc", line 12, in <module>
File "docx\opc\oxml.pyc", line 12, in <module>
File "lxml\etree.pyc", line 12, in <module>
File "lxml\etree.pyc", line 10, in __load
File "src/lxml/lxml.etree.pyx", line 92, in init lxml.etree
(src\lxml\lxml.etree.c:225327)
ImportError: cannot import name _elementpath