32 bit *.exe built on 64 bit Windows 7 still has references to 64 bit library

963 views
Skip to first unread message

harijay

unread,
Jan 27, 2012, 3:13:28 PM1/27/12
to pyins...@googlegroups.com
Hello,
I am running 64 bit windows 7 .

I have both 32 bit python and 64 bit python resident on my system. I
am trying to build a standalone exe file for my python application to
run on 32 bit Windows. 
The application is a wxpython application that creates a python script to a temp file that is called by subprocess.call from within the wxpython application. 
The eventual output is a pdf file written using the reportlab library.


After cloning pyinstaller from github, I ran the

c:\Python_32\python.exe pyinstaller.py C:\myproject\mymain.py


I could get an executable that launched right.  I have wxpython,
reportlab , pyyaml and other c-code containing python package dependencies.

However at runtime 

I am getting a "ImportError: DLL load failed: %1 is
not a valid Win32 application."

I am wondering how to build a 32 bit standalone application on my
machine and troubleshoot why the binary I have built with 32 bit
python is failing.

Thanks
Hari 

P.S: The older google groups frontend to this newgroup only gives an option to Mail the moderators. I sent two emails using that interface , but didnt see the message on the newsgroup .

The detailed error I see for the 32 bit app is :

Traceback (most recent call last):
  File "H:\test_scr.py", line 2, in <module>
    from gridder import masterplate,plate,component,buffercomponent
  File "C:\Python27\lib\site-packages\gridder\masterplate.py", line 12, in <modu
le>
    import pdfwriterlandscape, buffercomponent, awarepdfwriter, well
  File "C:\Python27\lib\site-packages\gridder\pdfwriterlandscape.py", line 6, in
 <module>
    from reportlab.pdfgen import canvas
  File "C:\Python27\lib\site-packages\reportlab\pdfgen\canvas.py", line 23, in <
module>
    from reportlab import rl_config
  File "C:\Python27\lib\site-packages\reportlab\rl_config.py", line 235, in <mod
ule>
    _startUp()
  File "C:\Python27\lib\site-packages\reportlab\rl_config.py", line 185, in _sta
rtUp
    from reportlab.lib.utils import rl_isdir
  File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 437, in <mod
ule>
    import urllib2
  File "C:\Python27\lib\urllib2.py", line 94, in <module>
    import httplib
  File "C:\Python27\lib\httplib.py", line 71, in <module>
    import socket
  File "C:\Python27\lib\socket.py", line 47, in <module>
    import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.



Martin Zibricky

unread,
Feb 2, 2012, 10:45:17 AM2/2/12
to pyins...@googlegroups.com
harijay píše v Pá 27. 01. 2012 v 12:13 -0800:

> I am wondering how to build a 32 bit standalone application on my
> machine and troubleshoot why the binary I have built with 32 bit
> python is failing.

Look at http://www.pyinstaller.org/wiki/HowtoReportBugs

Please examine the system PATH environment variable. Probably wx
installer set it to directory containing 64bit wx dlls.

Giovanni Bajo

unread,
Feb 2, 2012, 9:16:54 PM2/2/12
to pyins...@googlegroups.com
Il giorno 27/gen/2012, alle ore 21:13, harijay ha scritto:

Hello,
I am running 64 bit windows 7 .

I have both 32 bit python and 64 bit python resident on my system. I
am trying to build a standalone exe file for my python application to
run on 32 bit Windows. 
The application is a wxpython application that creates a python script to a temp file that is called by subprocess.call from within the wxpython application. 

When packaged with PyInstaller, what do you expect subprocess.call() to invoke? You can't directly running a Python script without a Python interpreter installed in the environment, and the packaged PyInstaller executable will not make this magically work for you. 

You will have to change this part of your program to use execfile() to invoke this script; this way, the script will get executed by the same Python interpreter/process running the main application. This will work only if the generated script does not import any package/module which was not included in the main application.

I could get an executable that launched right.  I have wxpython,
reportlab , pyyaml and other c-code containing python package dependencies.

However at runtime 

I am getting a "ImportError: DLL load failed: %1 is
not a valid Win32 application."

Sorry, I don't follow. Does this error happen when spawning the temporary file? 
-- 
Giovanni Bajo   ::  ra...@develer.com
Develer S.r.l.  ::  http://www.develer.com

My Blog: http://giovanni.bajo.it





hari jayaram

unread,
Feb 3, 2012, 9:15:24 AM2/3/12
to pyins...@googlegroups.com
Thanks Giovanni for your suggestion.

I ended up switching to execfile because of this realization.

I think the ""ImportError: DLL load failed: %1 " error was being
thrown when the native system python was being called by
subprocess.call["python" , "termp_scr.py"]
But after switching to execfile , I can run the temp script with the
modules "pre-loaded" into the wxpython calling program.


Hari

Reply all
Reply to author
Forward
0 new messages