You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PyInstaller将.py脚本打包为.exe时出现Runtime Error

Fixing PyInstaller RuntimeError: sip API Version Mismatch with PyQt5

Hey there, let's work through this PyInstaller packaging error you're hitting. That RuntimeError about sip and PyQt5's API version requirement is a straight-up version mismatch issue—here's how to resolve it:

Step 1: Verify Your Current Package Versions

First, check exactly what versions of sip/PyQt5-sip and PyQt5 you have installed. Run this command in your terminal:

  • On Windows:
    pip list | findstr /i "sip pyqt5"
    
  • On Linux/macOS:
    pip list | grep -E "sip|PyQt5"
    

You’ll likely see that your sip version is older than 12.4, while your PyQt5 expects v12.4+. Also, note that modern PyQt5 installations use PyQt5-sip (not the standalone sip package) as a dependency—if you have both installed, that’s probably part of the conflict.

Step 2: Align Your Package Versions

Here are two reliable fixes depending on your setup:

Option A: Upgrade to a Compatible sip/PyQt5-sip Version

If you have the standalone sip package, upgrade it to a version that matches PyQt5’s requirement:

pip install --upgrade sip

If that doesn’t work, specify the exact minimum version PyQt5 needs:

pip install sip==12.4

Option B: Clean Reinstall PyQt5 and Its Dependencies

If you’re seeing conflicts between sip and PyQt5-sip, do a clean install to ensure everything is aligned:

  1. Uninstall the conflicting packages:
    pip uninstall -y sip PyQt5 PyQt5-sip
    
  2. Reinstall PyQt5—this will automatically pull in the correct version of PyQt5-sip that’s compatible with your PyQt5 install:
    pip install PyQt5
    

Step 3: Double-Check Your Environment

  • If you’re using a virtual environment, make sure you’ve activated it before running the install/packaging commands. It’s easy to accidentally modify the global Python environment instead of your project’s.

Step 4: Retry PyInstaller

Once your packages are aligned, re-run your PyInstaller command (replace your_script.py with your actual script name):

pyinstaller --onefile your_script.py

Quick note: PyInstaller puts the final executable in the dist directory, not build—the build folder is just for temporary build files, so don’t panic if you don’t see the .exe there!

Give these steps a shot—version mismatches like this are super common with PyQt5 and sip, and aligning the packages almost always fixes the issue.

内容的提问来源于stack exchange,提问作者Luca Granalli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:57:01