I was directed here from Stack Overflow after posting a question about struggling to get PyExifTool to work. It seems however that the problem was multifaceted and being a novice I was told to seek help here.
Essentially the problem was realised when I was told to run...
bash:~ $ type -all exiftool
which returned...
exiftool is /usr/local/bin/exiftool
exiftool is /usr/local/bin/exiftool
...revealing that somewhere I had duplicates.
Subsequently, I ran...
bash:~ $ echo $PATH
Which returned...
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/fsl/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin~/.bash_profile
...which contains duplicates and apparently should not end with .bash_profile
Now in the terminal, I can clean this up using...
bash:~ $ PATH=$(echo $PATH | awk -v RS=: -v ORS=: '!($0 in a) {a[$0]; print}')
The above is a snippet that I got from Linux Journal that is supposed to 'nearly work' but the piece of code that 'should work' doesn't seem to help me. Using the 'nearly functional' code gives the following:
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/fsl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin~/.bash_profile :
I'm an utter novice but I don't think it's supposed to end in : and clearly the .bash_profile is still present. However, it does seem to remove duplicates, though this resets if I open a new terminal window so it's only an acute workaround.
This is what my bash profile looks like:
export PATH=/usr/local/bin:$PATH~/.bash_profile
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
#PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
#export PATH
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
#PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
#export PATH
# FSL Setup
FSLDIR=/usr/local/fsl
PATH=${FSLDIR}/bin:${PATH}
export FSLDIR PATH
. ${FSLDIR}/etc/fslconf/fsl.sh
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
I'm not sure if this is relevant or related but when I launch python from my Hotbar and run...
>>> print(os.environ['PATH'])
It prints
/usr/bin:/bin:/usr/sbin:/sbin
Whereas when I launch it from my bash terminal using IDLE3 it returns:
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/fsl/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin~/.bash_profile
Peripheral Information & Experimentation:
I think I probably messed something up when installing FSL, did something to my .bash_profile and am now being haunted while trying to learn and develop basic coding skills. Maybe it was a manual error or perhaps it had something to do with homebrew or Xcode.
I could delete the .bash_profile ending but I am concerned I have already done enough damage and don't want to troubleshoot myself into a problem so laborious no internet forum wants to touch it.
This is what was supposed to work according to Mitch Frazier from Linux Journal. Obviously this is no reflection on him or the article but rather on my limited understanding.
bash:~ $ export PATH=/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/fsl/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin~/.bash_profile
bash:~ $ echo -n $PATH | awk -v RS=: '!($0 in a) {a[$0]; printf("%s%s", length(a) > 1 ? ":" : "", $0)}'
This returns...
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/fsl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin~/.bash_profileUser's-MBP:~ username$
I have also tried the following (suggested by pepa65)...
bash:~ $ PATH=$(n= IFS=':'; for e in $PATH; do [[ :$n == *:$e:* ]] || n+=$e:; done; echo "${n:0: -1}")
This returns...
-bash: -1: substring expression < 0
When I try to look for changes using echo $PATH...
I get a blank line.
I know this is unlikely to be intellectually stimulating so I am grateful for any help.
EDIT 1:
A naive attempt to remove .bash_profile from the end of the first line of my .bash_profile did not make it disappear from the output of echo $PATH which remained unchanged.