When I run echo $PATH in terminal (macOS), it returns /opt/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. I have uninstalled anaconda and both my opt directory and .bash_profile are empty. When I run the which python command it returns : /usr/local/bin/python. In similar questions the problem is solved by removing the anaconda directory from the PATH environment variable but my ~/.bash_profile is empty.
Python is running fine in terminal but I'm guessing PATH runs through the empty directories where Anaconda files were located first? I am guessing this is not optimal and can create problems in the future?
Gordon Davisson's solution:
I am running zsh. Here's what I found in my z.profile :
# Setting PATH for Python 3.9
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/"
export PATHHere's what I found in .zshrc (when I tried to edit it said I "don't own the file" and should duplicate it to edit):
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then eval "$__conda_setup"
else if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then . "/opt/anaconda3/etc/profile.d/conda.sh" else export PATH="/opt/anaconda3/bin:$PATH" fi
fi
unset __conda_setup
# <<< conda initialize <<<I wasn't able to locate ~/.zlogin, ~/.zshenv or ~/.profile. But here's what I found in paths.d (not sure what the file "100-rvictl" is):
Last login: Mon Sep 6 17:21:00 on ttys001
me@mahmouds-mbp-2 ~ % /etc/paths.d/100-rvictl ; exit;
/etc/paths.d/100-rvictl: line 1: /Library/Apple/usr/bin: is a directory
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed] 3 1 Answer
It looks like the leftover PATH entry is coming from your ~/.zshrc file. The entire "conda initialize" section (from # >>> conda initialize >>> to # <<< conda initialize <<<) should be removed. If that's the only thing in the file, you can just delete the entire file. But if there are other things there you should edit it, and it'd be best to fix its ownership first.
Fixing file ownership: You can take ownership of the file with:
sudo chown "$UID" ~/.zshrc...but there might be other files with the same problem, so I'd recommend running ls -l ~ to list all the files in your home folder, and apply that fix to any others that aren't owned by you. For folders, use sudo chown -R "$UID" ~/foldername to get their contents as well.
BTW, the ownership problem is likely a result of some installer or setup script running as root (i.e. with sudo) rather than under your user ID, and therefore creating files owned by root rather than you.
Oh, and about that /etc/paths.d/100-rvictl file: it looks like you double-clicked it, which tried to run it as a script, which didn't really work (it's not a script). But from the contents, it's not related and shouldn't be a problem.