I have a program written in python that reads certain datafiles and produces a docx file and a pdf file. Now I need to distribute this, so I created a GUI and found that with py2exe I can create the .exe that I should then be able to distribute.
The .exe is created in the dist folder as it should be, and the GUI looks good too, but when I actually let the program do what it is supposed to do, I get the following error:
Package not found at 'C:\Users\heinreca\PycharmProjects\RaTeExe\dist\library.zip\docx\templates\default.docx'
And yes indeed there is no templates folder. I've been reading several stackoverflow posts and been googeling around, but have not found a solution yet.
One suggested solution was, to specify the data_files in my setup.py file like this:
data_files = [('template', 'C:/Users/heinreca/PycharmProjects/RaTeExe/venv/docx-template/*'), ]
setup(windows=['RaTe.py'],
options={
'py2exe':
{
'includes': ['lxml.etree', 'lxml._elementpath', 'gzip'],
}
},
data_files=data_files
)
But I get "No such file or directory: 'C'"
I tried doing this as a relative path with just \venv\docx-template* but this also doesn't work.
Another solution I found was to change a line about the path in the api.py file, however I can't find the api in dist, so I am not sure if I am misunderstanding something, or if this solution does not apply to my problem.
I also found the accepted solution here, but I don't understand it.
Another attempt was to already specify a path when creating the document with
document = Document('whatever/path/you/choose/to/some.docx')
as suggested here, but this also didn't work.
I am running out of ideas, and since I am always slightly overwhelmed when it comes to specifying paths, because I always seem to do something wrong, I would very much appreciate help with detailed explanations.
If you need more info about the program itself, let me know. Additionally: I work on windows 10, with pyCharm and python3.
Thanks!