[GIS] Having problems installing pyqt on Mac Os sierra

macpyqtqgisqgis-plugins

I am trying to write my first plugin following the tutorial at http://www.qgistutorials.com/en/docs/building_a_python_plugin.html.

Woking on a Mac running sierra.

The problem is that home brew will install only pyqt5 which, so far as I can tell, only works with python 3. At any rate it insists on installing python 3 and then dies trying to install sip but there are no obvious errors in the install log.

I then tried installing pyqt from https://doc.bccnsoft.com/docs/PyQt4/installation.html but again I failed to get sip installed. The page admits that "installation for mac os can be complex". I managed to build without problems but running make install tried to install sip in the same directory as python and mac os gave the error "Operation not permitted". Same thing happens if you try and add any file to that directory. Yes, I was using sudo 😉 It isn't a straight forward permission problem.

Update: The fundamental problem is that the python2.7 configure magic does not know about Mac OS SIP (System Integrity Protection) which prevents files in certain directories from being modified even by root.

I have spent a morning hacking the make files produced by various python configure scripts and managed to get sip (not to be confused with SIP, above) installed and to get the pyQT4 Core to find the include files but when I try to make pyQT I get the C compiler complaining about unknown type name which indicates that something is still wrong with the headers.

At this point I give up. I suspect that the python 2.7 development environment on Mac OS after El Capitan is seriously broken.

I'd be delighted if someone proves me wrong but I suspect the chances of anyone claiming the bonus are near zero.

Best Answer

I don't think it'll help, but below is my bash history where I was trying to work it out.

I think in the end I installed QT Creator, and didn't need pyqt4. You don't need to use make any more, from memory, the UI files are fine how they are. (It's probably time to update the plugin building docs!)

brew install pyqt
brew install pyqt5
make
pyrcc5
make
ls
pyrcc4
brew install pyqt4
brew install PyQt --with-python3
pip3 install pyqt5
brew install pyqt --with-python3
brew install pyqt
pb_tool compile
pip install pb_tool
pip3 install pb_tool
pb_tool compile
pyuic4 
brew install pyqt4
python --version
python pb_tool
pb_tool
pip3 uninstall pb_tool
pip --version
pip2.7
pip2.7 install pb_tool
pb_tool
pb_tool compile
brew install pyqt
brew test pyqt4
brew cleanup
brew update
bash ~/Downloads/Miniconda3-latest-MacOSX-x86_64.sh 
conda
/Users/alex/miniconda3/bin/conda install pyqt4
/Users/alex/miniconda3/bin/conda install pyqt
pyuic5 -o icsm_qgis_transformer_dialog.py icsm_qgis_transformer_base.ui
pyuic5 -o icsm_qgis_transformer_dialog.py 
icsm_qgis_transformer_dialog_base.ui