Guide to install PyQt5 on Mac OS X with python 2.7 virtualenv

时间:2022-11-20 20:28:08

Guide to install PyQt5 on Mac OS X with python 2.7 virtualenv

Requirements & Download

installation

  • install xcode
  • install the Command Line Tools (open Xcode > Preferences > Downloads)
  • install Qt libraries ( qt-opensource-mac-x64-clang-5.4.0.dmg )
  • create a virtual env
  • unzip and compile SIP and PyQt
  mkdir pyqt
  cd pyqt/
  virtualenv qtenv
  source qtenv/bin/activate

  mkdir tmp
  cp /Users/ge/Downloads/PyQt-gpl-5.4.1.tar.gz ./tmp
  cp /Users/ge/Downloads/sip-4.16.7.tar.gz ./tmp
  cd tmp/
  tar xvf sip-4.16.7.tar.gz 
  tar xvf PyQt-gpl-5.4.1.tar.gz 

  cd sip-4.16.7
  python configure.py -d /Users/ge/pyqt/qtenv/lib/python2.7/site-packages --arch x86_64
  make
  sudo make install
  sudo make clean

  cd ../PyQt-gpl-5.4.1
  python configure.py --destdir /Users/ge/pyqt/qtenv/lib/python2.7/site-packages --qmake /Applications/Qt/5.4/clang_64/bin/qmake 
  make
  sudo make install
  sudo make clean

  /Users/ge/pyqt/qtenv/bin/python -c "import PyQt5"