安装PySide2时Qt版本检测异常:已装高版本却提示需5.7+
Hey there, I totally get your confusion here—let's break down what's going on and fix this quickly!
The Root Cause
The error is happening because the qmake you're pointing to (/anaconda3/bin/qmake) belongs to the Qt 5.6.2 bundled with Anaconda, not the Qt 5.10/5.11 you installed via Homebrew. The PySide2 build script only checks the Qt version associated with the qmake path you specify, so it's picking up the old Anaconda version instead of your newer Homebrew install.
Step-by-Step Fix
Find the correct qmake path from your Homebrew Qt
Run this command to get the exact installation details of your Homebrew Qt:brew info qtLook for a line like
Installed to: /usr/local/Cellar/qt/5.10.1(or/opt/homebrew/Cellar/qt/5.11.xif you're on an Apple Silicon Mac). The qmake binary lives inside thebinfolder of this path.Update your build command with the right qmake path
Replace the--qmakeargument with the path you found. For example, if your Homebrew Qt 5.10 is installed at/usr/local/Cellar/qt/5.10.1, your command becomes:python setup.py build --qmake=/usr/local/Cellar/qt/5.10.1/bin/qmake --build-tests --ignore-git --jobs=8Double-check the qmake version (optional but recommended)
Before running the build, confirm you're targeting the correct Qt version by running:/usr/local/Cellar/qt/5.10.1/bin/qmake --versionThis should output Qt 5.10.x or 5.11.x, which confirms you're pointing to the right installation.
Extra Tip
If you want to avoid typing the full qmake path every time, add the Homebrew Qt bin directory to your PATH environment variable. For example, add this line to your ~/.zshrc (or ~/.bash_profile if using Bash):
export PATH="/usr/local/Cellar/qt/5.10.1/bin:$PATH"
Restart your terminal, and you can run the build command without the --qmake argument—PySide2 will automatically detect the correct, newer Qt version.
内容的提问来源于stack exchange,提问作者ecjb

