setup.py
from distutils.core import setup
import py2exe
setup(console=['program.py'])
The error
Traceback (most recent call last):
File "program.py", line 427, in <module>
File "program.py", line 242, in __init__
WindowsError: [Error 267] The directory name is invalid: 'C:\\Users\\Bob\applications\\Program\\test\\v0.6\\dist\\library.zip/*.*'
The directory name refers to a zip file called library which is located in the dist folder and created during the compilation.
Line 240 – 246 of program.py
file_list = []
root_dir = sys.path[0]
for path in os.listdir(root_dir):
full_path = os.path.join(root_dir, path).lower()
if os.path.isfile(full_path) and full_path.endswith('txt'):
# create list of (filename, dir) tuples
file_list.append((path.lower(), full_path))
Line 427 of program.py
gui = GuiTk(win)
Any ideas what causes the problem? I use Windows 7 64Bit and PortablePython 2.7.2.1 to create the executable. There are no other errors during the compilation procedure.
You are trying to list the items in
sys.path(). From docs:In the case of a py2exe executable like yours,
sys.pathis a list containing the path for library.zip (the archive that holds all the pure source modules py2exe find in your installation that could be needed for your executable to work).But you can not use a zip archive for the path for
os.listdirProbably you are not looking for sys.path but for the “current dir” as the name of your variable indicates.
If this is the case, then
os.getcwdwill do the job