py2exe doesn't copy imported module to .exe
Alexander Skwar
usenet-posting.zu.askwar at spamgourmet.com
Mon Mar 17 06:21:41 EST 2003
Hi!
I'm trying to use py2exe to distribute an application of mine. I've
written the following setup.py script:
#!/usr/bin/env python
from distutils.core import setup
from glob import glob
import py2exe
import os
import os.path
opj = os.path.join
from __version__ import *
from shutil import copyfile
def main():
data_files = [
('Images',
['Images\\X_Transparent.gif',
'Images\\X_swoosh_logo.ico',
'Images\\X_swoosh_logo_32x32x16.ico',
'Images\\X_swoosh_logo.jpg',
'Images\\X_swoosh_logo_32x32x16.ico.xpm',
'Images\\X_Transparent.xpm']),
('locale\\de\\LC_MESSAGES',
['locale\\de\\LC_MESSAGES\\xhc.mo'])
]
setup(
name = 'xhc',
version = '1.0',
scripts = ['xhc.py'],
description = 'X-Host Chooser',
author = 'Alexander Skwar',
author_email = 'askwar at email-server.info',
data_files = data_files
)
if __name__ == '__main__':
if not os.name in ('nt', 'dos'):
print "Error: setup.py can only be run in Windows or DOS!\n"
sys.exit(1)
main()
When I run the "compiled" version made by py2exe, I get the following error:
Traceback (most recent call last):
File "<string>", line 6, in ?
File "imputil.pyo", line 132, in _import_hook
File "<string>", line 101, in _finish_import
File "imputil.pyo", line 337, in _import_fromlist
ImportError: cannot import name XHCFrames.fHaupt
That's because my main script (xhc.py) imports a module 'fHaupt' from the
package 'XHCFrames' with "from XHCFrames import *" and uses it later on
with "self.main = fHaupt.create(None)".
The directory XHCFrames contains this __init__.py file:
# Package initialisation
__all__ = ['fHaupt']
The directory XHCFrames is directly underneath the directory containing
'xhc.py' - IOW: it's not in the system path.
I can run the xhc.py script just fine - the "compiled" xhc.exe dies with
the error message I've mentioned above.
What am I doing wrong?
Thanks a lot,
Alexander Skwar
--
printk("Penguin %d is stuck in the bottle.
", i);
2.0.38 /usr/src/linux/arch/sparc/kernel/smp.c
More information about the Python-list
mailing list