Maya 2023 is shipped with Python 3.9 only on all platforms. Although pip is shipped with Maya 2023, we still can’t use it to install PyQt5 on Mac. Unlike Maya 2023 on windows, pip installed packages could work. However, it has its own Qt5 libraries installed. 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.6, sip-6.5.1, PyQt5_sip-12.9.1 and PyQt-builder-1.12.2.
Windows:
We are going to build it with VS2019 which is same as Maya 2023’s developing environment on Windows. If you’ve installed a path needs Administrator Privileges, please run x64 Native Tools Command Prompt for VS 2019 as Administrator. I’ve installed my Maya 2023 to default location and I’ve extracted devkit to g:\case\devkitBase\2023. 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\maya2023"
2. Add your Maya2023\Python\scripts and Maya2023\bin to your system path. If you’ve created a subst drive, please use the path with drive. e.g.
set path=%path%;v:\bin;v:\Python\Scripts
3. Copy include\Python39\Python inside Maya2023 installation to Python\include. You’ll need to create the destination folder.
4. Copy lib\python39.lib inside Maya2023 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\2023\mkspecs\win32-msvc --qmake g:\case\devkitBase\2023\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 MacOSX Catalina or above, please install the latest Xcode 11. I’ve installed Maya 2023 to default path and extract devkit and PyQt5 source codes into ~/Documents/pyqt5.2023/. Please update the path in the scripts if you are using a different location. I am building it on Xcode 11 with Big Sur. 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. Install required Python packages.
sudo ./mayapy -m pip install toml
sudo ./mayapy -m pip install packaging
3. Go to sip source code folder. Build and install sip. e.g.
sudo /Applications/Autodesk/Maya2023/Maya.app/Contents/bin/mayapy setup.py install
4. Go to PyQt5_sip folder, install PyQt5_sip
sudo /Applications/Autodesk/Maya2023/Maya.app/Contents/bin/mayapy setup.py install
5. Go to PyQt builder folder, install PyQt builder.
sudo /Applications/Autodesk/Maya2023/Maya.app/Contents/bin/mayapy setup.py install
6. Use following script to build PyQt5. Please update the path with your Maya 2023 installation path.
#!/usr/bin/env bash
export PYTHONHOME=/Applications/Autodesk/maya2023/Maya.app/Contents/Frameworks/Python.framework/Versions/Current
export DYLD_LIBRARY_PATH=/Applications/Autodesk/maya2023/Maya.app/Contents/MacOS:$DYLD_LIBRARY_PATH
export DYLD_FRAMEWORK_PATH=/Applications/Autodesk/maya2023/Maya.app/Contents/Frameworks:$DYLD_FRAMEWORK_PATH
/Applications/Autodesk/Maya2023/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/bin/sip-install --jobs 16 --no-designer-plugin --spec ~/PyQt5.2023/devkit/mkspecs/macx-clang --qmake ~/PyQt5.2023/devkit/devkit/bin/qmake --verbose
Copy these scripts into a script file inside the directory of PyQt5 source files and execute it with sudo. If you can’t execute it, please use chmod +x filename to make it executable.
That’s it.
Linux
You can use pip to install PyQt5. e.g.
sudo mayapy -m pip install PyQt5
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