JiFu's Wiki JiFu's Wiki
首页
  • HTML
  • JavaScript
  • NodeJS
  • Vuejs
  • 微信小程序
  • Python
  • 数据库
  • 中间件
  • 算法
  • 软件工程
  • Wordpress
  • iOS开发
  • Android开发
  • Linux
  • Windows
  • MacOS
  • Docker
  • Vim
  • VSCode
  • Office
  • 其他
  • Photoshop
  • Sketch
  • Mac
  • 游戏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
首页
  • HTML
  • JavaScript
  • NodeJS
  • Vuejs
  • 微信小程序
  • Python
  • 数据库
  • 中间件
  • 算法
  • 软件工程
  • Wordpress
  • iOS开发
  • Android开发
  • Linux
  • Windows
  • MacOS
  • Docker
  • Vim
  • VSCode
  • Office
  • 其他
  • Photoshop
  • Sketch
  • Mac
  • 游戏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • DevOps介绍
  • Linux

  • MacOS

    • MacOS介绍
    • MacOS 如何提高 PDF 的对比度?
    • Charles从入门到精通
    • Compiling PyQt5 for Python 2.7 on MacOS
    • Homebrew让你从Mac切换到Linux更轻松
    • Mac OS X设置SMB进行文件共享
    • Mac OS系统加速:干掉那些「炫酷」的动画
    • Mac 时间机器 Time Machine 备份速度太慢的解决方法 (加速备份命令)
    • macOS 下 FFmpeg 视频转码入门及进阶使用心得
    • Mac定时任务-利用launchctl定时启动任务
    • Mac的最大连接数限制和端口的相关参数的设置
    • Mac重置系统管理控制器SMC
    • Mac高效使用技巧
    • MacOS一个惊人快速的终端录像工具
    • 一览Mac OS 图形界面的发展史
    • 修复Mac破解应用开打时闪退
    • 在M1芯片Mac上使用Homebrew
    • 如何查看 macOS 系统日志
    • 如何重置Mac上的NVRAM
    • 强制退出Mac程序的六种方法
    • 苹果 Mac 重置 SMC、NVRAM、PRAM 方法教程 - 解决 macOS 卡顿或无法启动
    • 苹果M1芯片Macbook安装win10
    • 解决“Mac应用”已损坏,无法打开的问题
    • 解决Mac修改DNS卡死-命令行修改Mac OS系统DNS设置
    • MacOS Photoshop屏蔽正版验证
    • 26.Karabiner自定义组合快捷键
    • MacOS软件推荐
    • Disable notification "to get future google chrome updates you'll need macos 10.13 or later" on mac
  • Windows

  • Docker

  • Vim

  • VSCode

  • Office

  • 其他

  • 运维
  • MacOS
JiFu
2023-10-18

Compiling PyQt5 for Python 2.7 on MacOS

This quick guide details compiling sip and PyQt5 on OS X 10.11 (El Capitan) using Homebrew for Qt5 installtion.

In case you don’t have Homebrew installed:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Let’s start with installing the latest version of Python 2.x, Qt5, as well as wget using brew:

brew install python qt5 wget

While that is “brewing”, make sure you have Xcode installed (can be installed via the Mac App Store). When Xcode is installed, also make sure you have its command-line tools installed and that you have agreed to Apple’s license agreement:

xcode-select --install sudo xcodebuild -license

Then let’s download the PyQt5 source for Linux and OS X and the prerequisite SIP source.

wget http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6/PyQt5_gpl-5.6.tar.gz wget http://freefr.dl.sourceforge.net/project/pyqt/sip/sip-4.18/sip-4.18.tar.gz

Double-check that the newly installed Python 2.7.x is being used when just executing python:

python --version

Untar and compile (also double check the path to your qmake):

tar -xvf sip-4.18.tar.gz
cd /sip-4.18
python configure.py -d /usr/local/lib/python2.7/site-packages/
make
make install

cd ..
tar -xvf PyQt-gpl-5.6.tar.gz
cd PyQt-gpl-5.6
python configure.py -d /usr/local/lib/python2.7/site-packages/ --qmake=/usr/local/Cellar/qt5/5.6.0/bin/qmake --sip=/usr/local/bin/sip --sip-incdir=../sip-4.18/siplib
make
make install
1
2
3
4
5
6
7
8
9
10
11
12

Please note, you may want want to check out the options in the configure.py files prior to configuring/compiling.

You may now import PyQt5 as a module in Python 2.7!

$ python

Python 2.7.10 (default, Sep 23 2015, 04:34:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
>>>
1
2
3
4
5
6
7
上次更新: 2024/08/11, 01:59:03
Charles从入门到精通
Homebrew让你从Mac切换到Linux更轻松

← Charles从入门到精通 Homebrew让你从Mac切换到Linux更轻松→

最近更新
01
WPS快捷键
05-21
02
Disable notification "to get future google chrome updates you'll need macos 10.13 or later" on mac
05-14
03
MacOS软件推荐
04-30
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Ji Fu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式