windows 下 pyinstaller distutils not included with latest virtualenv (16.4.0)

原由

由於windows下python3.7.2內置venv虛擬環境下pyinstaller錯誤問題,切換virtualenv可是發現最新版本又有其餘問題 - -!html

ModuleNotFoundError: No module named 'distutils'
[10373] Failed to execute script <name here>

排查

  1. 確定不是源碼問題,遷出代碼前沒有問題
  2. 可能又是virtualenv和pyinstaller的版本兼容問題

解決

直接搜索到了社區的解決方案python

# work-around for https://github.com/pyinstaller/pyinstaller/issues/4064
import distutils
if distutils.distutils_path.endswith('__init__.py'):
    distutils.distutils_path = os.path.dirname(distutils.distutils_path)

將以上代碼貼入 *.spec文件開頭,清理build目錄從新生成就能夠了。或等官方新版本解決git

相關文章
相關標籤/搜索