Due to a miscommunication between Elsevier Press and the Python Software Foundation, the first printing of this title used an unauthorized modification of the trademarked Python logo. We apologize to the PSF for this, and they have been understanding of our in-press status; in the 2nd and subsequent printing of this title, we shall use a cover design that has been approved as non-dilutive by the Python Software Foundation.

Help make the world a better place and make a secure donation to the Python Software Foundation today!

 

Building and Installing PyQt

Obtaining and installing everything needed for PyQt can be quite a task! Moreover, Maya 2012 requires some different steps to make sure you have all of the proper files needed to get going with PyQt. The information provided here should help you locate everything you need to download to be ready to build and install PyQt on your particular operating system, whether it is Windows, OS X, or Linux.

Overview and Download Links

If you have previously built the PyQt libraries for Maya 2011 and older, Autodesk has made some changes in the delivery of Qt in Maya 2012 and newer. There is now an Autodesk-customized version of the open source Qt framework, which is required for C++ or PyQt GUIs. Consequently, you do not need the complete Qt SDK for Maya 2012 and newer (because they use the Autodesk-modified version), but you can download the source packages of the Qt framework if you need access Qt Designer or anything else that comes with the framework.

Note that 32-bit and 64-bit versions of Qt cannot coexist in the same directory tree. If you want both versions installed on the same system then you will have to configure, build, and install Qt twice, using different installation directories each time.

The items you are going to need to download to prepare for building and installing PyQt are:

  1. An appropriate version of the Qt SDK for Maya 2011 and older, or Autodesk’s modified Qt source for Maya 2012 (under the heading QT4.7.1 modified for Maya)
  2. SIP, a C++ wrapper tool
  3. PyQt* (for Windows, use Python version 2.6, which is the version used in Maya 2012)
  4. Microsoft Visual Studio 2008, SP 1 (Windows only)**

*PyQt does not have the same licensing as Autodesk Maya, Qt, or Python. Please consult the PyQt website for information about licensing.
**These instructions should also work with Microsoft Visual Studio Express.

You do not need a specific version of SIP and PyQt—any recent version is good. PyQt keeps up with Qt, so anything after the compatible Qt version that is documented in the Maya API documentation is suitable. Once you have built and installed the first three components, you end up with PyQt binaries, which you put in your site-packages directory. Thereafter, you will be ready to start building custom PyQt GUIs!

Building and Installing PyQt

I am prefacing these build instructions by noting that I found I had to tinker with the settings and file locations to make it build. I have added in where I had to make adjustments, but everyone’s computer and environment is different, so what worked for me may not work for you. In spite of these few modifications, I successfully built and installed PyQt with Maya 2012, allowing me to create my PyQt custom GUIs for Maya 2012.

Jump to:

Windows

Building Qt

  1. Unzip the Qt package you downloaded from the Autodesk website, Qt-4.7.1-Modified_for_Maya.zip to a folder (e.g., C:\qt-adsk-4.7.1).
  2. Follow the instructions inside the zip file (howToBuildQtOnWindows_m2012.txt) to configure and build the modified Maya Qt SDK.

Building SIP

  1. Unzip the SIP package you downloaded from the Riverbank Computing website, sip-4.12.4.zip, to a folder (e.g., C:\sip-4.12.4).
  2. Start a Microsoft Visual Studio 2008 Command Prompt (Start -> All Programs -> Microsoft Visual Studio -> Visual Studio Tools -> Visual Studio 2008 Command Prompt).
  3. Change to the directory into which you extracted SIP.
    cd c:\sip-4.12.4
  4. Execute the following commands in the Command Prompt. The first line is required so the build can find python26.lib.
    set LIB=%LIB%;C:\Program Files\Autodesk\Maya2012\lib
    "C:\Program Files\Autodesk\Maya2012\bin\mayapy" configure.py
    nmake
    nmake install

SIP will now be installed in Maya’s site‐packages directory located at C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages.

Building PyQt

  1. Unzip the PyQt package you downloaded from the Riverbank Computing website, PyQt-win-gpl-4.8.5.zip, to a folder (e.g., C:\PyQt-win-gpl-4.8.5).
  2. Start a Microsoft Visual Studio 2008 Command Prompt.
  3. Change to the directory into which you extracted PyQt.
    cd c:\PyQt-win-gpl-4.8.5
  4. Execute the following commands in the Command Prompt. The PyQt configure.py script searches the PATH for a Qt installation. If you have other Qt installations, make sure they aren’t in the PATH.
    set QTDIR= c:\qt-adsk-4.7.1
    set PATH=c:\qt-adsk-4.7.1\bin;%PATH%
    set QMAKESPEC=C:\qt-adsk-4.7.1\mkspecs\win32‐msvc2008
    "C:\Program Files\Autodesk\Maya2012\bin\mayapy" configure.py ‐w LIBDIR_QT=C:\qt-adsk-4.7.1\lib INCDIR_QT=C:\qt-adsk-4.7.1\include

  5. You might get errors here so it is helpful to pipe it out to a file so you can see all the output.
    "C:\Program Files\Autodesk\Maya2012\bin\mayapy" configure.py -w LIBDIR_QT=C:\qt-adsk-4.7.1\lib INCDIR_QT=C:\qt-adsk-4.7.1\include > config.txt
    set INCLUDE=%INCLUDE%;C:\Program Files\Autodesk\Maya2012\include\python2.6;C:\qt-adsk-4.7.1\include
    nmake
    nmake install

If these commands result in errors referring to D:\qt, first search and replace all occurrences of D:\qt-adsk-4.7.1 to C:\qt-adsk-4.7.1 in all makefiles in the PyQt folder.

PyQt4 will now be installed in Maya’s site‐packages directory located at C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages.

OS X

Building Qt

  1. Unzip the package you downloaded from the Autodesk website, Qt-4.7.1-Modified_for_Maya.zip.
  2. Follow the instructions inside the zip file (howToBuildQtOnMac_m2012.txt), to configure and build the modified Maya Qt SDK.

Building SIP

  1. Open the Terminal application (Applications -> Utilities -> Terminal).
  2. Change to the directory into which you saved the SIP download, such as e.g.,
    cd ~/Downloads
  3. Execute the following lines to build SIP.
    tar ‐zxvf sip‐4.12.4.tar.gz
    cd sip‐4.12.4
    /Applications/Autodesk/maya2012/Maya.app/Contents/bin/mayapy configure.py ‐‐arch=x86_64
    make
    sudo make install

SIP will now be installed in Maya’s site‐packages directory located at /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages.

Building PyQt

  1. Open the Terminal application.
  2. Change to the directory into which you saved the PyQt download, such as e.g.
    cd ~/Downloads
  3. Execute the following lines to build PyQt.
    tar ‐zxvf PyQt‐mac‐gpl‐4.8.5.tar.gz
    cd PyQt‐mac‐gpl‐4.8.5
    export QTDIR=/usr/local/Trolltech/Qt‐4.8.5
    export PATH=/usr/local/Trolltech/Qt‐4.8.5/bin:$PATH
    export QMAKESPEC=/usr/local/Trolltech/Qt‐4.8.5/mkspecs/macx‐g++
    export DYLD_LIBRARY_PATH=/usr/local/Trolltech/Qt‐4.8.5/lib
    /Applications/Autodesk/maya2012/Maya.app/Contents/bin/mayapy configure.py
    LIBDIR_QT=/usr/local/Trolltech/Qt‐4.8.5/lib INCDIR_QT=/usr/local/Trolltech/Qt‐4.8.5/include
    MOC=/usr/local/Trolltech/Qt‐4.8.5/bin/moc ‐w ‐‐no‐designer‐plugin
    make ‐j8
    sudo make install
  4. PyQt will now be installed in Maya’s site‐packages directory located at /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4. At this point PyQt is installed, but the binaries are improperly linked for Maya, which must be corrected. Maya only includes the Qt binaries that it actually uses, so there are several installed PyQt modules which will not work because they won’t find the missing libraries. This problem can in theory be solved by copying in the missing libraries from the Qt build earlier. Execute the following lines in Terminal to do so.
    sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtCore.4.dylib @executable_path/QtCore {} \;
    sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtGui.4.dylib @executable_path/QtGui {} \;
    sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtSvg.4.dylib @executable_path/QtSvg {} \;
    sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtOpenGL.4.dylib @executable_path/QtOpenGL {} \;
    sudo find /Applications/Autodesk/maya2012/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.6/site‐packages/PyQt4 ‐name "*so" ‐exec install_name_tool ‐change libQtXml.4.dylib @executable_path/QtXml {} \;

Linux

Building Qt

  1. Unzip the package you downloaded from the Autodesk website, Qt-4.7.1-Modified_for_Maya.zip.
  2. Follow the instructions inside the zip file (howToBuildQtOnLinux_m2012.txt) in order to configure and build the modified Maya Qt SDK. In the instructions file, you can skip downloading the Qt SDK from the Nokia website, as we downloaded a custom version from the Autodesk website. There is also one incorrect item in this file. It says the default gcc version is 4.10 for Maya 2012, which is not the case. The default gcc version is 4.1.2 for Maya 2012.

Building SIP

  1. Open the Terminal application.
  2. Unzip the package you downloaded from the Riverbank Software website, sip-4.12.4.tar.gz.
  3. Execute the following commands in a command prompt:
    cd sip‐4.12.4
    /usr/autodesk/maya2012‐x64/bin/mayapy configure.py
    make
    sudo make install

SIP will now be installed in Maya’s site‐packages directory located at /usr/autodesk/maya2012‐x64/lib/python2.6/site‐packages/.

Building PyQt

  1. Unzip the package you downloaded from the Riverbank Software website, PyQt-x11-gpl-4.8.5.tar.gz.
  2. Execute the following commands in a command prompt:
    cd PyQt‐x11‐gpl‐4.8.5
    /usr/autodesk/maya2012‐x64/bin/mayapy configure.py ‐q /usr/local/Trolltech/Qt4.8.5/bin/qmake
    make ‐j4
    sudo make install

PyQt will now be installed in Maya’s site‐packages directory located at /usr/autodesk/maya2012‐x64/lib/python2.6/sitepackages/PyQt4.

~ by kristine on September 10, 2011.

12 Responses to “Building and Installing PyQt”

  1. found this link with a compiled PyQt for Windows 64bit and 32bit.
    http://nathanhorne.com/?p=322

  2. It’s going to be ending of mine day, however before finish I am reading this great post to improve my knowledge.

  3. you are truly a excellent webmaster. The website loading
    velocity is amazing. It kind of feels that you’re doing any distinctive trick.
    Furthermore, The contents are masterpiece. you’ve done a magnificent process on this topic!

  4. są zdecydowane oddać suma hec matrymonialnych, pospołu spośród krępującymi, jeśli
    przewidują że awansowanie się na nie
    da im zdeterminowaną przewagę. Są srodze sprytne plus jeśliby oczywiście bieżące mogę sformułować
    – surowe. W 4 fuksach na 5 poufale zaciekawione prowadzeniem
    stwierdzaj do zbitego funduszu.

  5. Amazing issues here. I’m very glad to look your article.
    Thank you so much and I’m looking ahead to toucch you. Will
    you please droip me a e-mail?

  6. After checking out a few of the blog articles on your web site, I seriously appreciate your way of blogging.
    I bookmarked it to my bookmark webpage list and will be checking back in the near future.

    Please check out my web site tooo and tell me your opinion.

  7. Wow, superb weblog format! How lengthy have you been blogging for?

    you make running a blog glance easy. The whole glance of youur web site is wonderful,
    let alone thhe content!

  8. Hi! I could have sworn I’ve been to this site before but after checking through
    some of the post I realized it’s new to me. Anyways, I’m definitely happy I
    found it and I’ll be book-marking and checking back frequently!

  9. Thanks for some other fantastic post. The place else could
    anybodyy get that type of information in shch a perfect means oof writing?

    I’ve a presentation next week, and I’m on the look for such info.

  10. http://programmer-veer.blogspot.in/2016/09/how-to-install-pyqt-for-maya-2013.html

  11. Everything is very open with a really clear explanation of
    the challenges. It was truly informative. Your website is
    useful. Thank youu for sharing!

  12. I see you don’t monetize maya-python.com, don’t waste your
    traffic, you can earn additional cash every month. There is one good way that brings decent money, you can google it: money making
    by bucksflooder

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.