Giovanni Bajo wrote:
On Fri, 2010-02-05 at 19:36 +0100, Marcin Krol wrote:
Giovanni Bajo wrote:

     raise ImportError, "No module named %s" % fqname
ImportError: No module named sqlalchemy
Of course, I agree that it's a bad default and should be changed. If you
think it's worth it, remove the current directory from sys.path at
startup.
I've done:

sys.path = [ p for p in sys.path if p.startswith('/usr/lib') ]

..at the beginning of the script and the packed binary STILL tries to import all the .py files in the current directory, resulting in above exception.

Try to print sys.path for debugging. It might well be possible that the
entry you want to remove is ".".


I have modified file iu.py to print sys.path in importHook and then mod.__dict__ in doimport:

        if mod:
            mod.__name__ = fqname
            if reload:
                sys.modules[fqname].__dict__.update(mod.__dict__)
            else:
                sys.modules[fqname] = mod
            if hasattr(mod, '__co__'):
                co = mod.__co__
                del mod.__co__
                try:
                    if reload:
                        exec co in sys.modules[fqname].__dict__
                    else:
                        print "mod.__dict__", mod.__dict__
                        exec co in mod.__dict__


I get this:
ATTENTION, sys.path: []
nm socket ctx None fqname socket
mod.__dict__ {'__name__': 'socket', '__file__': './socket.py', '__doc__': None}
Traceback (most recent call last):
  File "<string>", line 29, in ?
  File "/var/www/html/pyinstaller-py2.4/iu.py", line 441, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "/var/www/html/pyinstaller-py2.4/iu.py", line 527, in doimport
    exec co in mod.__dict__
  File "./socket.py", line 2, in ?
    raise AssertionError, "this is bad"
AssertionError: this is bad


I don't really understand your code very well, but I'd say that trying to import ./socket.py on empty sys.path AND doing "import socket" in code is not exactly what programmer using pyinstaller expects.

Regards,
mk


--
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to