2013-07-19 4 views
1

지난 주 필자는 pyinstaller/py2exe를 사용하여 몇 개의 python 스크립트와 pyqt .ui 파일을 exe에 컴파일하는 데 어려움을 겪었습니다. 나는 프로그래밍에 익숙하지 않으며 이전에 배포 용 응용 프로그램을 패키징하려 한 적이 없습니다.파이썬을 exe로 컴파일

지금까지 필자의 GUI 응용 프로그램을 하나의 python 스크립트로 단순화하는 데 성공했지만 py2exe 또는 pyinstall을 사용하여 컴파일하려고하면 동일한 오류가 발생합니다.

pyInstaller 중에 함께 오류는 다음과 같습니다

C:\Python27\pyinstaller-2.0>python utils\build.py costaharmplotter.spec 
109 INFO: Testing for ability to set icons, version resources... 
187 INFO: ... resource update available 
203 INFO: UPX is not available. 
2515 WARNING: library python%s%s required via ctypes not found 
2625 INFO: checking Analysis 
2625 INFO: building Analysis because out00-Analysis.toc non existent 
2625 INFO: running Analysis out00-Analysis.toc 
2625 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable 

2640 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21 
022.8_x-ww ... 
2640 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC90.CRT_1fc 
8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375.manifest 
2656 INFO: Searching for file msvcr90.dll 
2656 INFO: Found file C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_ 
9.0.21022.8_x-ww_d08d0375\msvcr90.dll 
2656 INFO: Searching for file msvcp90.dll 
2656 INFO: Found file C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_ 
9.0.21022.8_x-ww_d08d0375\msvcp90.dll 
2656 INFO: Searching for file msvcm90.dll 
2656 INFO: Found file C:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_ 
9.0.21022.8_x-ww_d08d0375\msvcm90.dll 
2812 INFO: Analyzing C:\Python27\pyinstaller-2.0\support\_pyi_bootstrap.py 
5484 WARNING: library python%s%s required via ctypes not found 
5562 INFO: Analyzing C:\Python27\pyinstaller-2.0\PyInstaller\loader\archive.py 
5875 INFO: Analyzing C:\Python27\pyinstaller-2.0\PyInstaller\loader\carchive.py 
6297 WARNING: pywintypes is changing its name to pywintypes27 
6797 INFO: Analyzing C:\Python27\pyinstaller-2.0\PyInstaller\loader\iu.py 
6843 INFO: Analyzing costaharmplotter.py 
Traceback (most recent call last): 
    File "<string>", line 1, in <module> 
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1844, in Tcl 
    return Tk(screenName, baseName, className, useTk) 
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1745, in __init__ 
    self.tk = _tkinter.create(screenName, baseName, className, interactive, want 
objects, useTk, sync, use) 
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    {C:\Tcl\lib\tcl8.5} C:/Python27/lib/tcl8.5 C:/lib/tcl8.5 C:/lib/tcl8.5 C:/li 
brary C:/library C:/tcl8.5.2/library C:/tcl8.5.2/library 

C:/Tcl/lib/tcl8.5/init.tcl: version conflict for package "Tcl": have 8.5.2, need 
exactly 8.5.13 
version conflict for package "Tcl": have 8.5.2, need exactly 8.5.13 
    while executing 
"package require -exact Tcl 8.5.13" 
    (file "C:/Tcl/lib/tcl8.5/init.tcl" line 18) 
    invoked from within 
"source C:/Tcl/lib/tcl8.5/init.tcl" 
    ("uplevel" body line 1) 
    invoked from within 
"uplevel #0 [list source $tclfile]" 


This probably means that Tcl wasn't installed properly. 

나는 py2exe에와 유사한 오류가 발생합니다 : 내 스크립트에서

C:\Documents and Settings\T53983\Desktop\HarmonicPlotterGUI>python setup.py py2e 
xe 
running py2exe 
*** searching for required modules *** 
*** parsing results *** 
Traceback (most recent call last): 
    File "setup.py", line 4, in <module> 
    setup(data_files=['C:\\Python27\\tcl\\tcl8.5\\init.tcl'], console = ['costah 
armplotter.py']) 
    File "C:\Python27\lib\distutils\core.py", line 152, in setup 
    dist.run_commands() 
    File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands 
    self.run_command(cmd) 
    File "C:\Python27\lib\distutils\dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 243, in run 
    self._run() 
    File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 299, in _run 
    py_files, extensions, builtins = self.parse_mf_results(mf) 
    File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 1097, in parse_ 
mf_results 
    tk = _tkinter.create() 
_tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    {C:\Tcl\lib\tcl8.5} C:/Python27/lib/tcl8.5 C:/lib/tcl8.5 C:/lib/tcl8.5 C:/li 
brary C:/library C:/tcl8.5.2/library C:/tcl8.5.2/library 

C:/Tcl/lib/tcl8.5/init.tcl: version conflict for package "Tcl": have 8.5.2, need 
exactly 8.5.13 
version conflict for package "Tcl": have 8.5.2, need exactly 8.5.13 
    while executing 
"package require -exact Tcl 8.5.13" 
    (file "C:/Tcl/lib/tcl8.5/init.tcl" line 18) 
    invoked from within 
"source C:/Tcl/lib/tcl8.5/init.tcl" 
    ("uplevel" body line 1) 
    invoked from within 
"uplevel #0 [list source $tclfile]" 


This probably means that Tcl wasn't installed properly. 

, 내가 NumPy와, pyqtgraph.PlotWidget, pyqt4를 사용합니다. QtCore 및 pyqt4.qtgui.

  • tkinter를 사용하지 않은 경우 왜 py2exe/pyinstaller가 tcl을 찾고 있습니까?
  • 문제의 원인이되는이 패키지를 제외하려면 어떻게합니까? 이미 tcl 파일을 tcl 8.5.13에서 tcl 8.5.2로 전환했지만 여전히 작동하지 않습니다.

저를 py2exe/pyinstaller 문서에 연결하지 마십시오. 저는 지난 며칠간 그것을 읽었으며 모든 옵션의 작동 방식을 이해하는 데 어려움을 겪고 있습니다. 나는 아래의 setup.py 파일과 spec 파일을 참조 용으로 게시 할 것이다.

setup.py 파일 :

from distutils.core import setup 
import py2exe 

setup(console = ['costaharmplotter.py']) 

spec 파일 : 나는 py2exe에 시도

# -*- mode: python -*- 
a = Analysis(['costaharmplotter.py'], 
      pathex=['C:\\Python27'], 
      hiddenimports=[], 
      hookspath=None) 
pyz = PYZ(a.pure - [('Tkinter','C:\\Python27\\lib\\lib-tk','PYMODULE')]) 
exe = EXE(pyz, 
      a.scripts, 
      exclude_binaries=1, 
      name=os.path.join('build\\pyi.win32\\costaharmplotter', 'costaharmplotter.exe'), 
      debug=False, 
      strip=None, 
      upx=True, 
      console=True) 
coll = COLLECT(exe, 
       a.binaries, 
       a.zipfiles, 
       a.datas, 
       strip=None, 
       upx=True, 
       name=os.path.join('dist', 'costaharmplotter')) 
+0

tcl 파일 형식을 .2로 변경 한 이유는 모르겠지만 프로그램에서 달리 지정해야한다고 나와 있습니다. – Qiu

답변

0

마지막으로, 나는 그것을 파이썬 2.6보다 새로운 것을 함께 작동하도록 얻을 수 없었다 . Sourceforge과 이전 update/news page을 보면 2.6/2.7보다 새로운 버전은 아직 지원되지 않는 것으로 보입니다.

2.7을 사용하는 것처럼 보입니다. 대신 파이썬 2.6으로 컴파일 해보십시오.

+0

방금 ​​시도한 것과 같은 오류가 발생했습니다. – user2502600

+0

죄송합니다. 그게 전부입니다. – TeaMug