PyQt4 issue with uber_subject.py

Hi AFNI team. I have been struggling to get uber_subject.py to run on my macbook.

[Michaels-MacBook-Pro-2:~] amlung% uber_subject.py

**** failed to import PyQt4.QtGui ****

PyQt4 must be installed to run the uber_subject.py GUI
→ see the output of: uber_subject.py -help_install

I executed all the steps described in the -help_install. I have confirmed that I have python2.7 installed, and PyQt4 is in the site-packages folder. I have also confirmed that PYTHONPATH points to /usr/local/lib/python2.7/site-packages

I am guessing I am missing something basic, but it is escaping me.

Can you please provide some guidance? Thank you!

Michael Amlung

Hi Michael,

What does the system check show?

afni_system_check.py -check_all

  • rick

Looks like theres an issue with install of PyQt4

bash-3.2$ afni_system_check.py -check_all
-------------------------------- general ---------------------------------
architecture: 64bit
system: Darwin
release: 16.0.0
version: Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; root:xnu-3789.1.32~3/RELEASE_X86_64
distribution: 10.12 x86_64
number of CPUs: 4
apparent login shell: tcsh (current shell is bash)
shell RC file: .cshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/amlung/abin/afni
afni version : Precompiled binary macos_10.12_local: Aug 14 2018
: AFNI_18.2.10
AFNI_version.txt : AFNI_18.2.10, macos_10.12_local, Aug 14 2018
which python : /usr/local/bin/python
python version : 2.7.16
which R : /usr/local/bin/R
R version : R version 3.3.2 (2016-10-31) – “Sincere Pumpkin Patch”
which tcsh : /bin/tcsh

instances of various programs found in PATH:
afni : 1 (/Users/amlung/abin/afni)
R : 1 (/Library/Frameworks/R.framework/Versions/3.3/Resources/bin/R)
python : 2
/usr/local/Cellar/python@2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/usr/bin/python
python2 : 1 (/usr/local/Cellar/python@2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
python3 : 1 (/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/bin/python3.7)

testing ability to start various programs…
afni : success
suma : success
3dSkullStrip : success
uber_subject.py : success
3dAllineate : success
3dRSFC : success
SurfMesh : success
3dClustSim : success

checking for R packages…
rPkgsInstall -pkgs ALL -check : FAILURE

    oo Warning: 
       These packages are not installed on the computer: brms!

checking for $HOME files…
.afnirc : found
.sumarc : missing
.afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
++ module ‘PyQt4’ found at /usr/local/lib/python2.7/site-packages/PyQt4
++ module loaded: PyQt4

** have PyQt4, but cannot load QtCore, QtGui; error is:


Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named sip


-------------------------------- env vars --------------------------------
PATH = /Applications/freesurfer/bin:/Applications/freesurfer/fsfast/bin:/Applications/freesurfer/tktools:/usr/local/fsl/bin:/Applications/freesurfer/mni/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/amlung/abin:/Applications/workbench/bin_macosx64/:/Applications/workbench/bin_macosx64:/Applications/workbench/bin_macosx64:/Applications/workbench/bin_macosx64:/Applications/workbench/bin_macosx64

PYTHONPATH = /usr/local/lib/python2.7/site-packages/

R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH (sub-shell) =
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) =

------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas : found TT_N27+tlrc under /Users/amlung/abin

------------------------------ OS specific -------------------------------
which brew : /usr/local/bin/brew
brew version : Homebrew 2.1.11

++ found PyQt4 under /usr/local/lib/python2.7/site-packages
– consider installing gcc under homebrew
– consider installing glib under homebrew
++ found 1 dylib files under ‘/opt/X11/lib/flat_namespace’
– found ‘libXt’ dylib files:
/opt/X11/lib/flat_namespace/libXt.6.dylib
– recent OS X, cheating to check DYLD_LIBRARY_PATH in cur shell ‘bash’…
** env var DYLD_LIBRARY_PATH not set to contain /opt/X11/lib/flat_namespace
– recent OS X, cheating to check DYLD_LIBRARY_PATH in shell ‘tcsh’…
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

========================= summary, please fix: =========================

  • missing R packages (see rPkgsInstall)
  • consider running “suma -update_env” for .sumarc
  • check for partial install of PyQt4
  • insufficient data for AFNI bootcamp
  • consider adding /usr/local/lib/python2.7/site-packages to PYTHONPATH
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in bash

Hi Rick, Any ideas on why its not working for us?

Hi Michael,

Sorry for not getting back to this.

It looks like you have this set up under homebrew, but maybe sip is not installed. Can you install that? I am not sure, but it might be just via “brew install sip”).

Can you give that a try? I do not have homebrew-based system to try these things out on.

  • rick

HI Rick,
Nope that was not the solution. Sip already installed and up to date. Should I try to wipe AFNI and do a clean install?

Well, AFNI isn’t the problem, set pyqt4 setup with homebrew is. You could try doing it via fink, instead, but that is doing a lot for a little package (pyqt4).

I think Brian has set up a virtual mac for us to test with. Maybe we can try installing pyqt4 via homebrew on there, and see how it goes.

What is the output from:

python -c 'from PyQt4 import QtCore, QtGui'

I think that is basically what needs to work.

Note that the afni_system_check.py output shows homebrew python2, homebrew pyqt4, and yet shows this error for loading PyQt4:

Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named sip

Maybe you have sip installed for python3, but not python2?

  • rick