- Created a virtual environment in my project folder and activated it.
python3 -m venv venv
# The last argument is the path to the virtual environment
source venv/bin/activate
- Updated pip
python3 -m pip install --upgrade pip
- Tried installing PyQt5 in virtual environment and failed
[ If it works you are good to go ]
pip install pyqt5
Some people also had the same issue, so I tried following the steps on Stack Overflow and a billion other sites but they all failed.
I also tried this: I installed qt globally on my mac using homebrew, added the path to qmake in environment variables and tried installing pyqt5 again in the virtual environment. But, the last step failed.
brew install qt5
echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc
Building pyqt5 might have been another option but I didn't want to get into that.
- Installed pyqt5 globally using homebrew (the previous step is needed for this)
brew install pyqt@5
Although it beats the point of virtual environments, I found this to be the only way.
- Allowed the virtual environment to access global packages (Stack Overflow)
python3 -m venv --system-site-packages venv