Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#42 Path incorrectly set for projects with package_dir (0.5.0)

Nick Mathewson

I'm not sure I've diagnosed this correctly; I hope you
can help.

My project has all of its python files under ./lib, and
uses distutils's 'package_dir' setting to find them
there. But starting with version 0.5.0, py2exe no
longer finds them there. If I manually add "./lib" to
the path, everything works again.

I'm attaching a minimal test case to demonstrate the
problem. When I run "python py2exe", it says

The following modules appear to be missing

But when I uncomment the commented-out line in
('sys.path.append("./lib")'), py2exe works fine again.

I am using Python 2.3.2 on Windows 2000. I did not
have this problem with older versions of py2exe.


  • Nick Mathewson
    Nick Mathewson

    Minimal failing case (zipped)

  • Thomas Heller
    Thomas Heller

    Logged In: YES

    My typical usage of py2exe has changed, I now always use
    separate setup scripts for building and installing my
    extension(s), and for building my exe-files - the setup
    scripts get too complicated.

    Does this make sense to you?

  • Logged In: NO

    Hm. I understand what you're saying, but I'm not clear what
    it implies for this bug. Are you saying that
    install-then-run-py2exe is the only official process, and
    other usage modes for py2exe are now unsupported? Or are
    you only suggesting a workaround?

    Personally, I prefer not to install first: if there is a
    problem in the code I'm trying to package, I would prefer
    not to replace any older copies in site-packages. But of
    course, if my use is unsupported, I could probably solve my
    needs by using a separate python installation for running

  • Thomas Heller
    Thomas Heller

    Logged In: YES

    I would like to add this code to py2exe, IMO it should fix
    your problem. At the very beginning of the run() method of
    py2exe/ file, please add these lines: = self.reinitialize_command('build')
    ........sys.path[:0] = [build.build_lib, build.build_platlib]

    Can you please try it out?

  • Nick Mathewson
    Nick Mathewson

    Logged In: YES

    Sorry about the delay: I tried your patch, and it seemed to
    solve the problem. Thanks!

  • Thomas Heller
    Thomas Heller

    • status: open --> closed-fixed