External Email - Use Caution
I don't think a script can see/read that shell alias. That’s why it worked in my example for the slicedelay script to run using a python rev 2 (which was /usr/bin/python = the *first* python returned when searching PATH) while the alias pointed to a completely different python (python3 found in PATH) to run from the terminal when you type “python”. You can put a hash bang line at the top of your scripts to specify them to run with a specific python found in PATH, e.g. below, instead of “python3", “python2” or anaconda python as found in your PATH.
- R. - - - ver.py - - -#!/usr/bin/env python3 import sys print(sys.version)- - - ver.py - - - $ ./ver.py3.6.8 (default, Aug 7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] On Oct 30, 2020, at 14:42, Peled, Noam <NPELED@mgh.harvard.edu> wrote:Thanks,In my system, I aliased the python command to a local anaconda python3.8.So to be able to use slicedelay, should I first alias python to python2? Thanks,Noam From: fsbuild <fsbuild@contbay.com> Sent: Friday, October 30, 2020 2:37 PMTo: freesurfer@nmr.mgh.harvard.eduCc: Peled, Noam <NPELED@mgh.harvard.edu>Subject: Re: [Freesurfer] preproc-sess error with FreeSurfer 7.1 External Email - Use Caution Please keep in mind that the system python installed on both CentOS6 and CentOS7 (/usr/bin/python) is python 2.X, so scripts aren’t expecting to run a version 3 via the “python” interpreter found in a standard system PATH. As far as I know only 1 python interpreter can be returned thru PATH (whichever python it finds first according to the order of the entries in PATH). But you can alias python to be something different in your shell, e.g., here using csh, % alias python python3… or alias to whatever python rev 3 you want to run. If your PATH is set to return system 2.X version, e.g., /usr/bin/python., then any script like slicedeleay should still find /usr/bin/python thru PATH. But typing python at the terminal will run whatever the alias points to. The which command will show you this (CentOS7), % which python/usr/bin/python% python --versionPython 2.7..5% alias python python3% python --versionPython 3.6.8% which pythonpython: aliased to python3% /usr/local/freesurfer/dev/bin/slicedelay --helpUSAGE: slicedelay --help --o slicedelayfile --nslices nslices : total number of slices in the volume --order order (up,down,odd,even,siemens) --ngroups ngroups (number of slice groups for SMS)< … rest of output deleted …>% unalias python% which python/usr/bin/python - R.On Oct 29, 2020, at 21:46, Peled, Noam <NPELED@mgh.harvard.edu> wrote: Thanks!I’m only working with python3, so I prefer to set python to call python3 and not python2.Is there an option to set the python bin file name used by FreeSurfer (/usr/bin/python2..7 for example)? Thanks,Noam From: fsbuild <fsbuild@contbay.com> Sent: Thursday, October 29, 2020 9:33 PMTo: freesurfer@nmr.mgh.harvard.eduCc: Peled, Noam <NPELED@mgh.harvard.edu>Subject: Re: [Freesurfer] preproc-sess error with FreeSurfer 7.1 External Email - Use Caution Hello Noam, The python script /usr/local/freesurfer/dev/bin/slicedelay needs to be run with a version of python that is 2.X, i.e., $ file /usr/local/freesurfer/dev/bin/slicedelay/usr/local/freesurfer/dev/bin/slicedelay: Python script, ASCII text executable $ which python2/bin/python2$ python2 /usr/local/freesurfer/dev/bin/slicedelay --helpUSAGE: slicedelay --help --o slicedelayfile --nslices nslices : total number of slices in the volume --order order (up,down,odd,even,siemens) --ngroups ngroups (number of slice groups for SMS) Creates an FSL custom slice delay file for use with slicetimer (--tcustom=sdfile).It has a single column of values, one for each slice. Each value is the slice delaymeasured as a fraction of the TR and range from +0.5 (beginning of the TR) to -0.5 (end of the TR).. Used for slice-time correction of fMRI. $ which python3/space/freesurfer/python/linux/bin/python3$ python3 /usr/local/freesurfer/dev/bin/slicedelay --help File "/usr/local/freesurfer/dev/bin/slicedelay", line 9 print "USAGE: slicedelay --help"; ^SyntaxError: Missing parentheses in call to 'print'. Did you mean print("USAGE: slicedelay --help")? So I think that means that for you,$ which python- is going to return a python from your PATH such that typing the command “python —version” will report it is rev 3.X and not 2.X. You can try setting the PATH environment variable such that the first python program found in PATH reports it is version 2.X. - R. On Oct 29, 2020, at 20:47, Peled, Noam <NPELED@mgh.harvard..edu> wrote: /usr/local/freesurfer/dev/bin/slicedelay_______________________________________________Freesurfer mailing listFreesurfer@nmr.mgh.harvard.eduhttps://mail.nmr.mgh..harvard.edu/mailman/listinfo/freesurfer%E2%80%8B______... mailing listFreesurfer@nmr.mgh.harvard.eduhttps://mail.nmr.mgh..harvard.edu/mailman/listinfo/freesurfer%E2%80%8B
freesurfer@nmr.mgh.harvard.edu