R and Python on MacOS M4

I encountered both of these problems when installing AFNI

  • missing R packages (see rPkgsInstall)
  • python library matplotlib is required
    (see AFNI install docs for details)

This is the check message:

-------------------------------- general ---------------------------------
architecture: 64bit Mach-O
cpu type: arm64
system: Darwin
release: 24.1.0
version: Darwin Kernel Version 24.1.0: Thu Nov 14 18:19:02 PST 2024; root:xnu-11215.41.3~13/RELEASE_ARM64_T8132
distribution: 15.1.1
number of CPUs: 10
apparent login shell: zsh
shell RC file: .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/Andy/abin/afni
afni version : Precompiled binary macos_13_ARM: Dec 24 2024
: AFNI_24.3.10 'Elagabalus'
AFNI_version.txt : AFNI_24.3.10, macos_13_ARM, 12 24 2024, buildAndy
which python : /opt/homebrew/opt/python/libexec/bin/python
python version : 3.13.1
which R : /usr/local/bin/R
R version : R version 4.3.1 (aarch64-apple-darwin20)

instances of various programs found in PATH:
afni : 1 (/Users/Andy/abin/afni)
R : 1 (/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/bin/R)
python : 1 (/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/bin/python3.13)
python2 : 0
python3 : 2
/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/bin/python3.13
/usr/bin/python3

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

------------------------ dependent program tests -------------------------
checking for dependent programs...

which tcsh : /bin/tcsh
tcsh version : 6.21.00
which Xvfb : /opt/X11/bin/Xvfb

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

    oo Warning: 
       These packages are not installed on the computer: afex!
    These packages are not installed on the computer: phia!
    These packages are not installed on the computer: snow!
    These packages are not installed on the computer: lme4!
    These packages are not installed on the computer: lmerTest!
    These packages are not installed on the computer: gamm4!
    These packages are not installed on the computer: paran!
    These packages are not installed on the computer: brms!
    These packages are not installed on the computer: corrplot!
    These packages are not installed on the computer: metafor!

R RHOME : /Library/Frameworks/R.framework/Resources

------------------------------ python libs -------------------------------

** failed to load module matplotlib.pyplot
-- matplotlib.pyplot is required

** failed to load module flask
-- flask is not required, but is desirable

** failed to load module flask_cors
-- flask_cors is not required, but is desirable

-------------------------------- env vars --------------------------------
PATH = /Users/Andy/miniconda3/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/opt/homebrew/opt/python/libexec/bin:/opt/homebrew/opt/python/libexec/bin:/opt/homebrew/opt/python/libexec/bin:/Users/Andy/abin:/opt/homebrew/opt/python/libexec/bin:/opt/homebrew/opt/python/libexec/bin

PYTHONPATH =
R_LIBS = /Users/Andy/sw/R-3.6.3
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH (sub-shell) = :/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) =
CONDA_SHLVL = 0
CONDA_DEFAULT_ENV =
CC =

----------------------------- eval dot files -----------------------------

----------- AFNI $HOME files -----------

.afnirc                   : found
.sumarc                   : found
.afni/help/all_progs.COMP : found

--------- shell startup files ----------

-- good: .tcshrc seems to contain 'source .cshrc'
-- considered operations: path, apsearch

-- note: followers should not need edits, so edit flags should be 0
(have 1 follower(s), which can be ignored)

no modifications needed across 3 dot files

------------------------------ data checks -------------------------------
data dir : found AFNI_data6 under $HOME (471482M Avail)
top history: 08 Nov 2024 [rickr/ptaylor]: add afni/bad_scripts
data dir : found AFNI_demos under $HOME
top history: 07 Nov 2024 [rickr]: shrank AFNI_pamenc tree
data dir : found suma_demo under $HOME
top history: ...s_New/data/Build_tmp on Mon Mar 4 11:56:45 EST 2013
data dir : found afni_handouts under $HOME
atlas : found TT_N27+tlrc under /Users/Andy/abin

------------------------------ OS specific -------------------------------
XQuartz version : 2.8.5

which brew : /opt/homebrew/bin/brew
brew version : Homebrew 4.4.13

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

  • just be aware: login shell 'zsh', but our code examples use 'tcsh'
  • missing R packages (see rPkgsInstall)
  • python library matplotlib is required
    (see AFNI install docs for details)

Hi Andy,

It great to see that you have gotten your hands on the coveted buildAndy distribution of the package! :)

For the missing R packages, note that you have R_LIBS set to ~/sw/R-3.6.3, which
is presumably from a previous distribution. You should change R_LIBS (in all of your dot files and your current shells) to ~/sw/R_4.3.1 (since that is what you have), and perhaps reboot to be sure, and then rebuild the library packages:

rPkgsInstall -pkgs ALL

For matplotlib (on a mac), the current recommendation is to use a miniconda environment.

  • rick

Thank you very much. Your advice has been very helpful. It has solved my problem
截屏2025-01-07 21.56.49