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

Mac OS Catalina系统下PyQt4安装问题求助(Anaconda环境)

Fixing PyQt4 Installation on macOS Catalina with Anaconda

Hey there, I feel your pain—stuck maintaining legacy PyQt4 code but hitting walls with Anaconda and pip not providing working packages for Catalina. Let’s break down the reliable workarounds to get this up and running:

Option 1: Compile PyQt4 from Source (Using Homebrew for Qt4)

Since official repositories dropped Qt4 support, we’ll use a third-party Homebrew tap to get Qt4, then build PyQt4 in your conda environment:

  1. Add the Qt4 Homebrew tap (official Homebrew removed Qt4 years ago):
    brew tap cartr/qt4
    
  2. Install Qt4 via Homebrew:
    brew install qt@4
    
  3. Create a dedicated conda environment (PyQt4 works best with Python 3.6 or older—newer versions have compatibility issues):
    conda create -n pyqt4_env python=3.6
    conda activate pyqt4_env
    
  4. Install a compatible SIP version (PyQt4 requires SIP < 5; version 4.19.13 is tested):
    pip install sip==4.19.13
    
  5. Set environment variables to let your conda Python find Qt4’s libraries and headers:
    export PATH="/usr/local/opt/qt@4/bin:$PATH"
    export DYLD_LIBRARY_PATH="/usr/local/opt/qt@4/lib:$DYLD_LIBRARY_PATH"
    export CFLAGS="-I/usr/local/opt/qt@4/include $CFLAGS"
    export LDFLAGS="-L/usr/local/opt/qt@4/lib $LDFLAGS"
    
  6. Install PyQt4 from source (skip pre-built wheels since they don’t work on Catalina):
    pip install PyQt4 --no-binary :all:
    
    Note: If Catalina blocks the Qt4 libraries afterward, go to System Preferences > Security & Privacy and allow the blocked software.

Option 2: Use a Third-Party Conda Repository

If compiling feels too tedious, try this third-party conda channel that still hosts PyQt4 packages:

conda create -n pyqt4_env python=3.6
conda activate pyqt4_env
conda install -c free pyqt=4

Heads up: This channel isn’t maintained as actively, so check for version conflicts with your other packages.

A Quick Note on Long-Term Maintenance

While these fixes get you up and running, keep in mind that PyQt4 is end-of-life and no longer receives security updates. If possible, consider incrementally migrating your code to PyQt5—most APIs are similar, and the transition is manageable with gradual refactoring.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 20:52:52