Hi Larry,
    bop, SiteConfig, bin and so on  are the subdirectories under c:\xbop_sinopec which is an application server.  I have appended the path: "c:\xbop_sinopec" to sys.path before I import them, so py2exe with python2.5 should search the path of  c:\xbop_sinopec for bop and SiteConfig.
    I have no problems to run my application started by "python main_sps_all02.py" for both python2.4 and python2.5. After py2exe compiled,  the binary from python2.4 is ok and the binary from python2.5 does not work. Running the binary from python2.5 first time, I got the error information:
            Fatal Python error: PyImport_GetModuleDict: no module dictionary! 
            ...
and running the binary from python2.5 second time and more, I got a different error message:
            Unhandled exception in thread started by
            Error in sys.excepthook:
            Orinignal exception was:
     After googling the web, the error looks like something related to "import in a thread"
               http://bugs.python.org/issue1720705
 
    but I am not sure about it.
    If I don't include the all listed modules manually, the binary after py2exeing  even with python2.4 does not work either.
    
Ouyang

 
2008/6/10 Larry Bates <larry.bates@websafe.com>:
zxo102 ouyang wrote:
> Hi there,
>     I have an python application and and  got no problem with
> py2exe under python2.4.  It works fine also if I start it by
> "c:\python25\python main_sps_all02.py". But after I compiled it with
> py2exe in python2.5, main_sps_all02.exe can not  "import" my modules
> anymore such as
>
>       from SiteConfig.SiteConfig import IP, PORT, QUEUE_SIZE
>       from bop.Exceptions import getException
>       from bop.Logger import logMessage
>       ....
> Anybody knows what is going on with py2exe in python2.5?   Thanks for
> your help in advance.
>
> My application file system, main_sps_all02.py and py2exe's setup.py are
> attached below.
>       # c:/xbop_sinopec
>       #    __init__.py
>       #    bin/
>       #       __init__.py
>       #       SSS/
>       #          __init__.py
>       #          main_sps_all02.py  #"current module"
>       #          Python25/
>       #              __init__.py
>       #              main_sps_all02.exe  # binary file after py2exe
> "compiled" main_sps.py
>       #    bop/
>       #        __init__.py
>       #        Exceptions.py
>       #        Logger.py
>       #        SessionManager.py
>       #        ...
>       #        db/
>       #            __init__.py
>       #            DatabaseManager.py
>       #  SiteConfig/
>       #        __init__.py
>       #        SiteConfig.py
>       # ....
>
> ######### main_sps_all02.py #################
> #!c:/python25/python.exe
> ## -*- coding: utf-8 -*-
> import threading
> import os,sys
>
> class ThreadTwo ( threading.Thread ):
>    def run (self):
>       xbopHome = "C:\\xbop_sinopec"
>       sys.path.insert(0, xbopHome)
>       from SiteConfig.SiteConfig import IP, PORT, QUEUE_SIZE
>       from bop.Exceptions import getException
>       from bop.Logger import logMessage
>
>       from bop.db.DatabaseManager import databaseManager
>       from bop.SessionManager import SessionManager
>       from bop.Server import Server
>
>       sessionManager = SessionManager()
>       sessionManager._state_lock_ = 0
>       f = open(os.path.join(xbopHome, 'pid'), 'w')
>       f.write(`os.getpid()`)
>       f.close()
>       server = Server(sessionManager, IP, PORT, QUEUE_SIZE)
>       server.start()
> if __name__=="__main__":
>    xbopThread = ThreadTwo()
>    xbopThread.start()
>
>
>
> ##### py2exe setup.py #######################################
>
> from distutils.core import setup
> import py2exe
> import sys
> import glob
> from distutils.filelist import findall
> import os
> import matplotlib
> matplotlibdatadir = matplotlib.get_data_path()
> matplotlibdata = findall(matplotlibdatadir)
> matplotlibdata_files = []
> for f in matplotlibdata:
>     dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
>     matplotlibdata_files.append((os.path.split(dirname)[0], [f]))
> excludes = ["pywin.debugger", "pywin.debugger.dbgcon",
>             "pywin.dialogs", "pywin.dialogs.list",'_gtkagg', '_tkagg']
> #, "win32com.client"]
> includes=['aifc','anydbm','asynchat','asyncore','atexit','audiodev','base64','BaseHTTPServer','Bastion','bdb',
> 'binhex','bisect','bsddb','bsddb.*','calendar','cgi','CGIHTTPServer','cgitb','chunk','cmd',
> 'code','codecs','codeop','colorsys','commands','compileall','compiler','compiler.*','ConfigParser','Cookie',
> 'cookielib','copy','copy_reg','csv','curses','curses.*','dbhash','decimal','difflib','dircache',
> 'dis','distutils','distutils.*','doctest','DocXMLRPCServer','dumbdbm','dummy_thread','dummy_threading','email','email.*',
> 'encodings','encodings.*','filecmp','fileinput','fnmatch','formatter','fpformat','ftplib','getopt','getpass',
> 'gettext','glob','gopherlib','gzip','heapq','hmac','hotshot','hotshot.*','htmlentitydefs','htmllib',
> 'HTMLParser','httplib','idlelib','idlelib.*','ihooks','imaplib','imghdr','imputil','inspect','keyword',
> 'linecache','locale','logging','logging.*','macpath','macurl2path',
> 'mailbox','mailcap','markupbase','mhlib','mimetools','mimetypes','MimeWriter','mimify','modulefinder','multifile',
> 'mutex','netrc','new','nntplib','ntpath','nturl2path','opcode','optparse','os','os2emxpath',
> 'pdb','pickle','pickletools','pipes','pkgutil','platform','popen2','poplib','posixfile','posixpath',
> 'pprint','profile','pstats','pty','pyclbr','pydoc','py_compile','Queue','quopri','random',
> 're','repr','rexec','rfc822','rlcompleter','robotparser','sched',
> 'sets','sgmllib','shelve','shlex','shutil','SimpleHTTPServer','SimpleXMLRPCServer','site',
> 'smtpd','smtplib','sndhdr','socket','SocketServer','sre','sre_compile','sre_constants','sre_parse',
> 'stat','statvfs','string','StringIO','stringold','stringprep','subprocess','sunau','sunaudio',
> 'symbol','symtable','tabnanny','tarfile','telnetlib','tempfile','textwrap','this',
> 'threading','timeit','toaiff','token','tokenize','trace','traceback','tty','types',
> 'unittest','urllib','urllib2','urlparse','user','UserDict','UserList','UserString','uu','warnings',
> 'wave','weakref','webbrowser','whichdb','xdrlib','xml','xml.*','xmllib','xmlrpclib',
> 'zipfile','_LWPCookieJar','_MozillaCookieJar','_strptime','_threading_local','__future__']
> packages=['pyodbc','pyExcelerator','ctypes','serial','matplotlib','numpy','pytz']
> options = {
>     "ascii": 1, # to make a smaller executable, don't include the encodings
>     "compressed": 0, # compress the library archive
>     "skip_archive": 1,
>     "excludes": excludes, # COM stuff we don't want
>     'dll_excludes':
> ['libgdk-win32-2.0-0.dll','libgobject-2.0-0.dll','libgdk_pixbuf-2.0-0.dll','wxmsw26uh_vc.dll','python22.dll','tk83.dll','tcl83.dll'],
>     "includes": includes,
>     "packages": packages,
>     "dist_dir": "Python25",
>     }
> setup(
>       name='xbop',
>       version='1.0',
>       description='wisco point monitoring',
>       author='zxo102',
>       author_email='yyy@gmail.com' <mailto:author_email='yyy@gmail.com'>,
>       url='http://xbop.objectis.net/',
>       console=['main_sps_all02.py'],
>     options = {"py2exe": options},
>     data_files=matplotlibdata_files
>     )
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Py2exe-users mailing list
> Py2exe-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/py2exe-users

Did you copy the libraries for (bob and SiteConfig) from
C:\Python24\libs\site-libs to C:\Python25\libs\site-libs or include them in the
PYTHONPATH environment variable?

Also: why are you hard including all the listed modules?  py2exe will find the
ones he needs automatically.  You only need includes for non-standard modules
like plug-ins that don't use normal imports, etc.  You may be making the
library.zip a lot larger than is necessary.

You are also excluding python22.dll and it isn't going to get included under 2.5.

Hope this helps.

-Larry


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Py2exe-users mailing list
Py2exe-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/py2exe-users