2016-03-01 145 views
2

我有一個PyQt應用程序,我試圖用PyInstaller 3.1編譯成一個exe文件。它編譯成exe文件,但是,啓動時不顯示GUI(單擊exe文件)。其中一條編輯信息是:PyInstaller無法找到pyqt4插件目錄

ImportError: No module named site 5576 ERROR: Cannot find PyQt4 plugin directories 5576 WARNING: Hidden import 'PyQT4._qt' not found (probably old hook)

我覺得這就是爲什麼UI不會顯示出來。我已經在分析對象的pathex屬性中添加了PyQt4的所有路徑,但都無濟於事。下面是我的spec文件:

# -*- mode: python -*- 

block_cipher = None 


a = Analysis(['main32.py'], 
      pathex=['C:/OSGeo4W/apps/Python27/Lib/site-packages/PyQt4','./src'], 
      binaries=None, 
      datas=None, 
      hiddenimports=[], 
      hookspath=None, 
      runtime_hooks=None, 
      excludes=None, 
      win_no_prefer_redirects=None, 
      win_private_assemblies=None, 
      cipher=block_cipher) 
pyz = PYZ(a.pure, a.zipped_data, 
      cipher=block_cipher) 
exe = EXE(pyz, 
      a.scripts, 
      a.binaries, 
      a.zipfiles, 
      a.datas, 
      name='MyExe', 
      debug=False, 
      strip=None, 
      upx=True, 
      console=False) 

任何想法是下一個試試?

+0

是'site'包通過你的書面或它的庫的依賴? – Astery

回答

1

我有同樣的錯誤,我也做這個解決:

  1. 卸載PyQt4的(「PIP卸載PyQt4的」在CMD);

  2. 刪除「PyQt4」文件夾「... PythonX \ Lib \ site-packages \」;

  3. 從這裏下載網站「.whl」包:Python Expansion Packages你需要下載權WHL,看文件的名稱,因爲即時通訊使用Python3.5,文件「PyQt4-4.11 .4- cp35 -none-win32.whl「爲我工作!

  4. 再次安裝,在該文件的位置和打字打開CMD: 「PIP安裝PyQt4-4.11.4-CP35-NONE-win32.whl」。當然你會輸入你的文件名。

Note: Only by uninstalling, I could compile my script. But if you are really using PyQt4 code, you gonna need to install it again. Please, thumbs up if it worked for you too! ;)