matplotlib error with @ss_review

Hey guys:

I am having problems running the review driver script that is outputted from the following command:


apqc_make_tcsh.py -review_style pythonic -subj_dir . -uvar_json out.ss_review_uvars.json

After some previous output the error is as follows:


AFNI QUITTs!
\n+* Removing temporary image directory 'QC_sub-S14V1A/media/__tmp_chauf_zB5fIsj7aot'.\n
[1]    Done                          Xvfb :156 -screen 0 1024x768x24
Traceback (most recent call last):
  File "/Users/nixonsghost/abin/1dplot.py", line 40, in <module>
    import lib_plot_1D as lpod
  File "/Users/nixonsghost/abin/lib_plot_1D.py", line 23, in <module>
    import matplotlib.pyplot  as plt
ImportError: No module named matplotlib.pyplot
Traceback (most recent call last):
  File "/Users/nixonsghost/abin/1dplot.py", line 40, in <module>
    import lib_plot_1D as lpod
  File "/Users/nixonsghost/abin/lib_plot_1D.py", line 23, in <module>
    import matplotlib.pyplot  as plt
ImportError: No module named matplotlib.pyplot
Traceback (most recent call last):
  File "/Users/nixonsghost/abin/1dplot.py", line 40, in <module>
    import lib_plot_1D as lpod
  File "/Users/nixonsghost/abin/lib_plot_1D.py", line 23, in <module>
    import matplotlib.pyplot  as plt
ImportError: No module named matplotlib.pyplot
Traceback (most recent call last):
  File "/Users/nixonsghost/abin/1dplot.py", line 40, in <module>
    import lib_plot_1D as lpod
  File "/Users/nixonsghost/abin/lib_plot_1D.py", line 23, in <module>
    import matplotlib.pyplot  as plt
ImportError: No module named matplotlib.pyplot

I run this command after successful preprocessing and the problem is with the -review_style pythonic option because when I do not use this option the QC output is generated successfully. I have used the driver script with the pythonic option before and it worked. I think the issue is with either my .bash_profile or .cshrc file and I would like to get all of my programs available to AFNI once and for all and I was wondering if you could help me.

When I run the AFNI system check I get the following output:


-------------------------------- general ---------------------------------
architecture:         64bit
system:               Darwin
release:              18.6.0
version:              Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64
distribution:         10.14.5 x86_64
number of CPUs:       8
apparent login shell: bash  (current shell is csh)
shell RC file:        .cshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/nixonsghost/abin/afni
afni version         : Precompiled binary macos_10.12_local: Jul  3 2019
                     : AFNI_19.2.01 'Claudius'
AFNI_version.txt     : AFNI_19.2.01, macos_10.12_local, Jul 03 2019
which python         : /usr/local/bin/python
python version       : 2.7.16
which R              : /usr/local/bin/R
R version            : R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
which tcsh           : /bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/Users/nixonsghost/abin/afni)
    R       : 2
      /Library/Frameworks/R.framework/Versions/3.4/Resources/bin/R
      /Users/nixonsghost/anaconda2/bin/R
    python  : 4
      /usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/bin/python2.7
      /Users/nixonsghost/anaconda2/bin/python2.7
      /sw/bin/python2.7
      /usr/bin/python
    python2 : 2
      /usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/bin/python2.7
      /Users/nixonsghost/anaconda2/bin/python2.7
    python3 : 2
      /usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/bin/python3.7
      /Library/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!
        These packages are not installed on the computer: metafor!


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

------------------------------ python libs -------------------------------
** python module not found: PyQt4
-- PyQt4 is no longer needed for an AFNI bootcamp

python binaries under /sw/bin:
    /sw/bin/python       (sym link to /sw/bin/python2.7)
    /sw/bin/python2.7

-------------------------------- env vars --------------------------------
PATH = /Applications/ANTs/bin/bin:/Applications/freesurfer/bin:/Applications/freesurfer/fsfast/bin:/Applications/freesurfer/tktools:/usr/local/fsl/bin:/Applications/freesurfer/mni/bin:/Applications/MATLAB_R2017a.app/bin:/Applications/ANTs/bin/bin:/Applications/freesurfer/bin:/Applications/freesurfer/fsfast/bin:/Applications/freesurfer/tktools:/usr/local/fsl/bin:/Applications/freesurfer/mni/bin:/Applications/MATLAB_R2017a.app/bin:/Users/nixonsghost/dcm2niix/dcm2niix/build/bin/:/usr/local/bin:/usr/local/sbin:/Users/nixonsghost/anaconda2/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/opt/qt/bin:/Applications/ANTs/bin:/Applications/ANTs/bin:/Applications/freesurfer/bin:/Applications/freesurfer/fsfast/bin:/Applications/freesurfer/tktools:/usr/local/fsl/bin:/Applications/freesurfer/mni/bin:/usr/local/fsl/bin:/sw/bin:/sw/sbin:/Users/nixonsghost/dcm2niix/dcm2niix/build/bin:/bin:/usr/bin:/Applications/MATLAB_R2017a.app/bin:/Users/nixonsghost/Applications/freesurfer/bin:/Users/nixonsghost/Applications/freesurfer/fsfast/bin:/Users/nixonsghost/Applications/freesurfer/tktools:/usr/local/fsl/bin:/Users/nixonsghost/Applications/freesurfer/mni/bin:/opt/local/bin:/opt/local/sbin:/usr/local/fsl/bin:/usr/sbin:/sbin:/usr/local/bin:opt/X11/bin:/Users/nixonsghost/abin:/Users/nixonsghost/abin:/opt/X11/bin:/opt/metasploit-framework/bin:/opt/metasploit-framework/bin:/Users/nixonsghost/abin:/opt/X11/bin:/sw/lib/qt4-mac/lib/python2.7/site-packages:/Users/nixonsghost/abin:/opt/X11/bin:/sw/lib/qt4-mac/lib/python2.7/site-packages

PYTHONPATH = /Users/nixonsghost/anaconda2/bin

R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH (sub-shell) = /Applications/freesurfer/lib/gcc/lib:/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) =

------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME/Downloads/CD
           top history: ...9 [ptaylor]: added FT_analysis/results.QC_FT.05 tree
data dir : found AFNI_demos   under $HOME/Downloads/CD
           top history: 22 Apr 2019 [rickr]: added AFNI_pamenc
data dir : missing suma_demo
data dir : found afni_handouts under $HOME/Downloads/CD
atlas    : found TT_N27+tlrc  under /Users/nixonsghost/abin

------------------------------ OS specific -------------------------------
which fink           : /sw/bin/fink
fink version         : Package manager version: 0.43.1
which brew           : /usr/local/bin/brew
brew version         : Homebrew 2.1.7
which port           : /opt/local/bin/port
port version         : Error: Current platform "darwin 18" does not match expected platform "darwin 17"

++ found 'brew' at /usr/local/bin/brew
++ found PyQt4 under /sw/lib/qt4-mac/lib/python2.7/site-packages
** warning: have fink PyQt4, but non-fink python /usr/local/bin/python
++ 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 'csh'...
++ found evar DYLD_LIBRARY_PATH = /Applications/freesurfer/lib/gcc/lib:/opt/X11/lib/flat_namespace

=========================  summary, please fix:  =========================
*  login shell 'bash', trusting user to translate code examples from 'tcsh'
*  shell bash: consider sourcing (non-login) .bashrc from (login) .bash_profile
*  missing R packages (see rPkgsInstall)
*  insufficient data for AFNI bootcamp
*  consider adding /sw/lib/qt4-mac/lib/python2.7/site-packages to PYTHONPATH
*  have fink PyQt4, but non-fink python /usr/local/bin/python

I get that this is a matplotlib problem from the error and, as I’ve said, I think it’s just a matter of something being inconsistent in one of my startup files. It seems I have a fink downloaded PyQT4 but non-fink python and, to be honest, I never understood how those things interacted.
My current PYTHONPATH variable is set to my anaconda folder: /Users/nixonsghost/anaconda2/bin. When I try to replace or add to this path with /sw/lib/qt4-mac/lib/python2.7/site-packages my AFNI system check will return a segmentation fault. I have tried adding the /sw/lib/qt4-mac/lib/python2.7/site-packages to the PATH variable but I receive the same matplotlib error. I had bee told previously this could potentially be a DYLD_LIBRARY_PATH issue but if that is the case I do not know how to proceed.

I am not sure if this will be helpful but I have attached screenshots of the relevant parts of my .bash_profile (10.20.02) and my .cshrc (10.17.56)

Thanks for any guidance.
Lauren

Hi Lauren,

It looks like you just need to install matplotlib for python2.

However, with 4 versions of python2 installed, it could be easy to get them mixed up. You seem to be running the one out of /usr/local/bin, which is from homebrew, so it install it via something like:

brew install matplotlib
  • rick

Hey Rick:

Hate to bother you with this again. So running


brew install matplotlib

doesn’t actually work anymore. I guess it migrated? Anyway, to get that specific code to work now you’d do:


brew tap brewsci/science
brew info brewsci/science/matplotlib --json=v1
brew install brewsci/bio/matplotlib

The reason I’m posting is that, while this code will run, it installs matplotlib to my python3.7/site-packages, not my python2.7 so the issue persists. Is there a workaround similar to pip2 that you’re aware of that would get this installed to 2.7 specifically?

It’s obviously not a dealbreaker issues since running it with -basic works but I feel like this’ll come back and bite me with something else down the line.

Thanks, Rick.
Lauren

Hi Lauren,

While, I have not tried this, the scipy.org folks suggest this:

python -m pip install --user matplotlib

That is the same as what matplotlib.org shows, except scipy.org suggests --user, to keep this local to your user account. The local install makes a lot of sense.

Also, note that most of our python programs should work with python 3, if that is something you are thinking about moving towards.

  • rick