2013-02-01 2 views
1

PyQt를 사용하여 작은 응용 프로그램을 만들고 py2exe로 실행 가능한 설정을 만들었습니다. 내 랩탑에서 모두 훌륭하지만 다른 시스템에 응용 프로그램을 배포하려고 할 때 열 수 없으며 .log 파일에서 다음 오류를 제공합니다.PyQt 및 Py2exe 응용 프로그램 시작 오류 및 문제를 해결하는 방법?

Traceback (most recent call last): 
    File "viewer.py", line 5, in <module> 
    File "PyQt4\QtCore.pyo", line 12, in <module> 
    File "PyQt4\QtCore.pyo", line 10, in __load 
ImportError: DLL load failed: %1 is not a valid Win32 application. 

나는이 시도를 많이했지만 시도하지 못했습니다. 도와주세요 !!

편집 : 여기

은 setup.py

#!/usr/bin/python 
import sys 
#C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91 

#sys.path.append("C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\redist\\x86\\Microsoft.VC90.CRT") 


import warnings 
warnings.filterwarnings(action="ignore", message='the sets module is deprecated') 
from distutils.core import setup 
import py2exe 

manifest = ''' 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
manifestVersion="1.0"> 
<assemblyIdentity 
version="0.64.1.0" 
processorArchitecture="x86" 
name="Controls" 
type="win32" 
/> 
<description>Your Application</description> 
<dependency> 
<dependentAssembly> 
<assemblyIdentity 
    type="win32" 
    name="Microsoft.Windows.Common-Controls" 
    version="6.0.0.0" 
    processorArchitecture="X86" 
    publicKeyToken="6595b64144ccf1df" 
    language="*" 
/> 
</dependentAssembly> 
</dependency> 
</assembly> 
''' 

''' 
installs manifest and icon into the .exe 
but icon is still needed as we open it 
for the window icon (not just the .exe) 
changelog and logo are included in dist 
''' 

sys.path.append('C:\\WINDOWS\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91') 

excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon", 
      "pywin.dialogs", "pywin.dialogs.list"] 

setup(
#options = {"py2exe": {"includes":["sip"],"dll_excludes": ["MSVCP90.dll"]}}, 
options = {"py2exe": {"typelibs": 
          # typelib for WMI 
          [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)], 
          # create a compressed zip archive 
          "compressed": 1, 
          "optimize": 2, 
          "excludes": excludes, 
          "includes":["sip","PyQt4"]}}, 

    # The lib directory contains everything except the executables and the python dll. 
    # Can include a subdirectory name. 
    zipfile = "lib/shared.zip", 

windows = [ 
    { 
    "script": "viewer.py", 
    #"icon_resources": [(1, "favicon.png")], 
    #"other_resources": [(24,1,manifest)] 
    } 
    ], 
    data_files=["msvcm90.dll","msvcp90.dll","msvcr90.dll"] 

) 

답변

0

당신은 그래서 우리는 그것을 좀 걸릴 수 있습니다 당신의 setup.py를 게시해야합니다. 아무튼,이 효과에 뭔가 py2exe setup.py 작동합니다. 우리의 설정에서 작동하려면 bundle_files 및 zipfile 매개 변수를 조정해야 할 수도 있습니다. 'QT 경로를 여기에 삽입하십시오'를 QT dll의 적절한 경로로 바꾸고 'a.dll', 'b.dll', 'c.dll'에 대한 실제 QT dll 이름을 입력하십시오.

setup.py :

# USAGE: 'python setup.py py2exe' 
from distutils.core import setup 
import py2exe, sys 

sys.argv.append('py2exe') 

setup(
    data_files=[ 
       ('.','viewer.ico']), 
       ('insert qt path here', ['a.dll','b.dll', 'c.dll']) 
       ], 

    options={'py2exe':{ 
         'bundle_files': 1, # 3 - Don't pack, 2 - Pack all but interpreter, 1 - pack all. 
         'unbuffered':  True, 
         'optimize':  2, 
         'compressed':  1 
         }, 
      }, 

    windows=[ 
      { 
       'script':'viewer.py', 
      }, 
      ], 

    zipfile = None# None = All in EXE does not work with tcl/ttk gui's, Else 'shared.lib' make a lib file with name specified. 
) 
+0

감사합니다! 지금 setup.py 코드를 추가했습니다! – Mahendra

0

오류 메시지

File "form1.pyc", line 11, in ? 
    File "qt.pyc", line 9, in ? 
    File "qt.pyc", line 7, in __load 
ImportError: No module named sip 

솔루션 답장을 보내

python setup.py py2exe --includes sip