I am trying to create an exe file from my program written in Python 2.7 (using GTK+ layouts). I have consulted this guide: http://www.py2exe.org/index.cgi/Py2exeAndPyGTK and tried to set up my files accordingly. I succesfully make an .exe file, but when trying to run it, i get this error:
Traceback (most recent call last):
File "cipherka.py", line 183, in <module>
File "cipherka.py", line 18, in __init__
GError: Nelze otevřít soubor "C:\Repa\cipherka\dist\library.zip\gui.xml": No such file or directory
While I cannot find the gui.xml file in the library.zip archive, it is available on the same level as the main .exe (cipherka.exe) file. If i copy it into the .zip file on my own, it doesn't solve the problem.
Here is my setup.py file:
from distutils.core import setup
import py2exe
import glob
setup(
name="cipherka",
windows = [
{
'script': 'cipherka.py',
}
],
options = {
'py2exe': {
'packages':'encodings',
'includes': 'cairo, pango, pangocairo, atk, gobject, gio',
}
},
data_files=['gui.xml',
'README',
("modules", glob.glob("modules/*.*")),
("media", glob.glob("media/*.png"))
]
)
Any help will be wildly appreciated! And I can give you any necessary info when needed. Thx
Allright, I implemented the change. However, it does weird things. When i use:
path = os.path.dirname(__file__).replace('\\library.zip','')
it works when ran from the .py file, but fails when compiled with this error:
Traceback (most recent call last):
File "cipherka.py", line 217, in <module>
File "cipherka.py", line 18, in __init__
NameError: global name '__file__' is not defined
When i use
path = os.path.dirname('gui.xml').replace('\\library.zip','')
instead - the program stops running from python and the compiled version gives me the following:
C:\Repa\cipherka\dist\cipherka.exe:188: GtkWarning: gtk_tree_path_append_index: assertion `index >= 0' failed
C:\Repa\cipherka\dist\cipherka.exe:188: GtkWarning: gtk_tree_model_get_iter: assertion `path->depth > 0' failed
Traceback (most recent call last):
File "cipherka.py", line 217, in <module>
File "cipherka.py", line 55, in __init__
File "cipherka.py", line 188, in changed_cb
IndexError: could not find tree path
Any ideas?
"gui.xml"
is in "C:\Repa\cipherka\dist\"
, not "C:\Repa\cipherka\dist\library.zip"
as your code supposes.
This should work whether your program is compiled or not.
path = os.path.dirname(__file__).replace('\\library.zip','')
xml_file = open(os.path.join(path, 'gui.xml'))