1

I am using a Catalina macOS. I previously was able to work with my python installations with ease on this system. But today after updating other packages, such as wget and julia, I have encountered these errors zsh: command not found: python3.8 on my terminal. Following suggestions on these links I have tried to modify the PATH and zshrc but none of these approaches enables me to solve my problem. I would be grateful if you can share your suggestions on how to deal with this issue.

Here are some of the outputs of my system.

zshrc:

vi ~/.zshrc

alias python=/usr/local/bin/python3.8
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/shasa/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
if [ -f "/Users/shasa/anaconda3/etc/profile.d/conda.sh" ]; then
    . "/Users/shasa/anaconda3/etc/profile.d/conda.sh"
else
    export PATH="/Users/shasa/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<

python:

which python
python: aliased to /usr/local/bin/python3.8

PATH:

echo $PATH 
/Users/shasa/anaconda3/bin:/Users/shasa/anaconda3/condabin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin

Edit 1: In /usr/local/bin/, I can see that python3@, python3.9@ and python3.8@* are present. Do you think the extra * near python3.8@ can cause this problem? If yes, how can resolve that?

Shasa
  • 173
  • 1
  • 10
  • and have you checked `file /usr/local/bin/python3.8`? – hjpotter92 Feb 02 '21 at 12:01
  • Yes! The path seems correct as I can see python3.8@* in this directory. – Shasa Feb 02 '21 at 12:05
  • have you `source ~/.zshrc` after you edited it? – Paul Brennan Feb 02 '21 at 12:22
  • yeah, I did that. – Shasa Feb 02 '21 at 12:56
  • 2
    `@` means it is a symlink, that doesn't guarantee that the linked file is present. check with `readlink -f /usr/local/bin/python3.8` – hjpotter92 Feb 03 '21 at 06:08
  • @Shasa : If you manually invoke `/usr/local/bin/python3.8 --version` instead of `python --version`, what do you get? – user1934428 Feb 03 '21 at 10:17
  • @hjpotter92 with `-n` instead of `-f` I get: `../Cellar/python@3.8/3.8.5/bin/python3.8%` – Shasa Feb 03 '21 at 10:39
  • @user1934428 I am getting `zsh: no such file or directory: /usr/local/bin/python3.8`. I have already reinstall python3.8 using `brew` – Shasa Feb 03 '21 at 10:42
  • @Shasa : Well, then you have your bug! hjpotter92 was right after all. It means that _brew_ did not install Python to where you hope it would do. Now you have two options: Either you can find out where your Python installation ended up (and then fix your alias), or you can't (and then post this problem at [superuser](https://superuser.com/), because it is then off-topic at SO). – user1934428 Feb 03 '21 at 10:45
  • I see. Good to notice that. Thanks, @hjpotter92 and @user1934428! – Shasa Feb 03 '21 at 11:07
  • 1
    @user1934428 you can also use the shortcut `[su]` for it to auto-expand to [su]. :) same for `[so]`, `[sf]` just in case you didn't know – hjpotter92 Feb 03 '21 at 11:25
  • @hjpotter92 : No, I didn't! Very helpful indeed! – user1934428 Feb 04 '21 at 07:50
  • @Shasa "Following the discussion in the comments, I have found the source of the problem." Please put your solution into an answer and then accept your own answer. That way, your question doesn't stay open as unresolved _and_ if anyone else in future has the same problem, they will be able to find the answer more easily. – Marlon Richert Feb 05 '21 at 09:30

1 Answers1

1

Following the discussion in the comments, I have found the source of the problem. I run brew doctor and indeed found out that the python3.8 symlinks were broken. I have then removed broken symlinks by brew cleanup and reinstalled that again.

Shasa
  • 173
  • 1
  • 10