1
當我嘗試改變我的腳本在一個可執行文件,我得到這個錯誤,它的完成之後:錯誤而轉化的.py到.EXE
Traceback (most recent call last):
File "shd-WinResize.py", line 4, in <module>
File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32api.pyd
我使用這個腳本轉換:
from distutils.core import setup
import py2exe
import sys
sys.argv.append('py2exe')
setup(
options = {'py2exe': dict(bundle_files=1, optimize=2)},
windows = ["shd-WinResize.py"],
zipfile = None,
)
,這裏是我的程序的源:
import pyHook
import pythoncom
import win32api
import win32console
import win32gui
hideConsole = win32console.GetConsoleWindow()
win32gui.ShowWindow(hideConsole, 0)
def OnKeyboardEvent(event):
if event.Ascii == 49:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1440, 900, True)
elif event.Ascii == 50:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1366, 768, True)
elif event.Ascii == 51:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1280, 1024, True)
elif event.Ascii == 52:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1280, 960, True)
elif event.Ascii == 53:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1280, 800, True)
elif event.Ascii == 54:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1280, 768, True)
elif event.Ascii == 55:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1152, 864, True)
elif event.Ascii == 56:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 1024, 768, True)
elif event.Ascii == 57:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 800, 600, True)
elif event.Ascii == 48:
windowFocused = win32gui.GetForegroundWindow()
win32gui.MoveWindow(windowFocused, 0, 0, 640, 480, True)
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
有什麼錯呢?
我想壓縮,我想要捆綁... 我該怎麼辦?
嘗試在生成的可執行文件運行dependencywalker(這是一個免費的自包含下載),看看你錯過了什麼... – ChristopheD 2010-02-26 07:01:47
不是依賴的win32api.pyd ? – Shady 2010-02-26 14:49:22