Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8088279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:02:34+00:00 2026-06-05T19:02:34+00:00

setup.py from distutils.core import setup import py2exe setup(console=[‘program.py’]) The error Traceback (most recent call

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:02:36+00:00Added an answer on June 5, 2026 at 7:02 pm

    You are trying to list the items in sys.path(). From docs:

    sys.path A list of strings that specifies the search path for
    modules. Initialized from the environment variable PYTHONPATH, plus an
    installation-dependent default.

    As initialized upon program startup, the first item of this list,
    path[0], is the directory containing the script that was used to
    invoke the Python interpreter. If the script directory is not
    available (e.g. if the interpreter is invoked interactively or if the
    script is read from standard input), path[0] is the empty string,
    which directs Python to search modules in the current directory first.
    Notice that the script directory is inserted before the entries
    inserted as a result of PYTHONPATH.

    In the case of a py2exe executable like yours, sys.path is 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.listdir

    >>> import os
    >>> d = 'C:\\test.zip'
    >>> os.listdir(d)
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
    WindowsError: [Error 267] El nombre del directorio no es válido: 'C:\\test.zip/*.*'
    >>> 
    

    Probably 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.getcwd will do the job

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple setup: from distutils.core import setup setup(name='myscripts', description='my scripts', author='Ago',
My setup.py looks something like this: from distutils.core import setup setup( [...] install_requires=['gevent', 'ssl',
I have setup.py in a buildout project: from distutils.core import setup setup(name='', version='1.0', author='Denis
I'd like to call Python's distutils' or setuptools' setup() function in a slightly unconventional
Attempting to build .exe using py2exe: python setup.py py2exe , receiving error: ImportError: No
After migrating my whole setup from Java 1.5 to 1.6 (J2EE, Tomcat) a couple
I need to learn more about creating setup projects from within Visual Studio to
Using Visual Studio 2008 - I add a Setup project (from Setup and Deployment
This is the code section from inno setup.My intention is to make two Checkbox
I'm trying to setup a simple timer that gets started from a Rails Application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.