Maya 2024 is shipped with Python 3.10 only on all platforms. Although pip is shipped with Maya 2024, we still can't use it to install PyQt5 on Mac or Linux. On windows, pip installed packages could work. However, it has its own Qt5 libraries installed and it may lead to problems. You may want to replace them with the ones shipped with Maya. I didn't encounter any problems during my testing with the original pip packages. If you find any problems with it, you can build your own with this guide.
When I am writing this guide, I am building with PyQt5-5.15.9, sip-6.7.7, PyQt5_sip-12.11.1 and PyQt-builder-1.14.1.
Windows:
We are going to build it with VS2022 which is same as Maya 2024's developing environment on Windows. If you've installed a path needs Administrator Privileges, please run x64 Native Tools Command Prompt for VS 2022 as Administrator. I've installed my Maya 2024 to default location and I've extracted devkit to g:\case\devkitBase\2024. Please update it with the paths on your computer. Here are the steps:
1. Subst your maya install folder to a dedicate drive if there is a space inside your maya installation path. I am going to subst it to drive v e.g.
subst v: "C:\Program files\Autodesk\maya2024"
2. Add your Maya2024\Python\scripts and Maya2024\bin to your system path. If your've created a subst drive, please use the path with drive. e.g.
set path=%path%;v:\bin;v:\Python\Scripts
3. Copy include\Python310\Python inside Maya2024 installation to Python\include. You'll need to create the destination folder.
4. Copy lib\python310.lib inside Maya2024 installation to Python\libs. You'll need to create the destination folder. Once you've copied the libarary, please duplicate one and name it as python3.lib.
5. Go to sip source folder. Use mayapy install sip. e.g.
v:\bin\mayapy setup.py install
6. install PyQt-builder and PyQt5-sip with pip
mayapy -m pip install PyQt-builder
mayapy -m pip install PyQt5-sip
7. Download devkit, unzip the mkspec in the mkspec folder directly into its directory. Unzip the Qt include files into the include directory directly. Rename include\qtnfc to qtnfc.disabled.
8. Update mkspecs/common/msvc-desktop.conf in the mkspecs, enable shell and add COM libraries to build config.
QMAKE_LIBS = ole32.lib OleAut32.lib
QMAKE_LIBS_QT_ENTRY = -lqtmain -lshell32
9. Go to PyQt5 source folder. Use following command to install PyQt5. Please update the devkit path with the one on your computer.
sip-install --jobs 32 --no-designer-plugin --spec g:\case\devkitBase\2024\mkspecs\win32-msvc --qmake g:\case\devkitBase\2024\devkit\bin\qmake.exe --verbose
The jobs count shouldn't be more than the count of your logical processors. I am using a 5950x which has 32 logical processors so the jobs is 32 here. If you don't want debug output, please remove the —verbose flag in the end.
Vola, it works.
Mac:
If you are going to install it on MacOS Ventura or above, please install the latest Xcode 14. I've installed Maya 2024 to default path and extract devkit and PyQt5 source codes into ~/Documents/pyqt5.2024/. Please update the path in the scripts if you are using a different location. I am building it on Xcode 14 with Ventura. If you had encountered issue on a different building environment, please let us know.
1. Download devkit, unzip the mkspec in the mkspec folder directly into its directory. Unzip the Qt include files into the include directory directly. Rename include\qtnfc to qtnfc.disabled.
2. As the day I've written this blog, the sip-install can't add python libraries correctly on my testing environment with XCode 14.1 on Ventura. So, I've added them manually. Open mkspecs\common\clang-mac.conf. add
-lpython3.10 -L/Applications/Autodesk/maya2024/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib
to the and of QMAKE_LFLAGS. I tried to use -F flag to add framework path and it was failed. I've created a temporary Python framework at /Library/Frameworks/Python.framework with ln
sudo ln -s /Applications/Autodesk/maya2024/Maya.app/Contents/Frameworks/Python.framework/Python Python
3. Install required Python packages.
sudo ./mayapy -m pip install ply
sudo ./mayapy -m pip install toml
sudo ./mayapy -m pip install packaging
4. Go to sip source code folder. Build and install sip. e.g.
sudo /Applications/Autodesk/Maya2024/Maya.app/Contents/bin/mayapy setup.py install
5. Go to PyQt5_sip folder, install PyQt5_sip
sudo /Applications/Autodesk/Maya2024/Maya.app/Contents/bin/mayapy setup.py install
6. Go to PyQt builder folder, install PyQt builder.
sudo /Applications/Autodesk/Maya2024/Maya.app/Contents/bin/mayapy setup.py install
7. Go to PyQt5 source folder and install PyQt5 with following command.
sudo /Applications/Autodesk/Maya2024/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/bin/sip-install --jobs 16 --no-designer-plugin --spec ~/PyQt5.2024/devkit/mkspecs/macx-clang --qmake ~/PyQt5.2024/devkit/devkit/bin/qmake --verbose
That's it.
Linux
If you are going to install it on MacOS Ventura or above, please install the latest Xcode 14. I've installed Maya 2024 to default path and extract devkit and PyQt5 source codes into ~/maya/2024/ separately. Please update the path in the scripts if you are using a different location. I am building it on Almalinux 8.7. If you had encountered issue on a different building environment, please let us know.
1. Download devkit, unzip the mkspec in the mkspec folder directly into its directory. Unzip the Qt include files into the include directory directly. Rename include\qtnfc to qtnfc.disabled.
2. Enable gcc-toolset-11
scl enable gcc-toolset-11 bash
3. Duplicate Python 3.10 include. The compiler will find the python libraries in maya2024/include/python3.10. Maya2024 ship it path maya2024/include/Python310/Python. We'll need to duplicate it to make it work.
cd /usr/autodesk/maya2024/include
sudo mkdir python3.10
sudo cp ../Python310/Python/* . -r
4. Install required Python packages.
sudo ./mayapy -m pip install ply
sudo ./mayapy -m pip install toml
sudo ./mayapy -m pip install packaging
5. Go to sip source code folder. Build and install sip. e.g.
sudo /usr/autodesk/maya2024/bin/mayapy setup.py install
6. Go to PyQt5_sip folder, install PyQt5_sip
sudo /usr/autodesk/maya2024/bin/mayapy setup.py install
7. Go to PyQt builder folder, install PyQt builder.
sudo /usr/autodesk/maya2024/bin/mayapy setup.py install
8. Go to PyQt5 source folder and install PyQt5 with following command.
sudo /usr/autodesk/maya2024/bin/sip-install --jobs 16 --no-designer-plugin --spec ~/PyQt5.2024/devkit/mkspecs/macx-clang --qmake ~/PyQt5.2024/devkit/devkit/bin/qmake --verbose
We have finished installing PyQt5 for Maya 2024 on Linux.
Test your installation
After install PyQt5, you can use following script to test your installation.
import sys
from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton)
from PyQt5.QtGui import QFont
class Example(QWidget):
def __init__(self):
super(Example,self).__init__()
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget')
btn = QPushButton('Button', self)
btn.setToolTip('This is a <b>QPushButton</b> widget')
btn.resize(btn.sizeHint())
btn.move(50, 50)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Tooltips')
self.show()
ex = Example()
Comments
You can follow this conversation by subscribing to the comment feed for this post.