I have a Python application. It loads configuration files (and other files) such as:
_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CONFIG_DIR = os.path.join(_path, 'conf')
It works great. However, when I package my application with py2exe, bad things happen:
File "proj\config.pyc", line 8, in <module>
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\proj\
\dist\\library.zip\\conf'
Obviously the wrong way ... What is a more reliable way to do this? I do not want to specify absolute paths in the program, because they can be placed in different folders. Should I just say "if it says that the name of the folder is" library.zip ", then go one more level down to the" dist "folder?
Note that I have fairly nested directory hierarchies ... for example, I have the gui.utils.images module stored in "gui / utils / images.py" and it uses its own path for example to access "gui /images/ok.png ". Right now, the py2exe version would try to access "proj / dist / library.zip / gui / images / ok.png" or something else that just wouldn't work.
source
share