alias-tips icon indicating copy to clipboard operation
alias-tips copied to clipboard

_alias_tips__preexec:34: command not found: python

Open andig opened this issue 2 years ago • 5 comments

Recently getting this message on OSX:

~/htdocs
❯ which python
_alias_tips__preexec:34: command not found: python
python not found

~/htdocs
❯ which python3
_alias_tips__preexec:34: command not found: python
/opt/homebrew/bin/python3

andig avatar Mar 17 '22 11:03 andig

Thanks @andig for reporting. The python version is currently hardcoded to python3.

Do you have an idea how to best route to Python 3 via python or python3? I know that some distributions have defaulted to have python actually be Python 3, yet I am not aware of a good heuristic to figure that out.

djui avatar Mar 17 '22 12:03 djui

I wouldn‘t know- not a regular python user. One option might be checking for python3 and then fall back to python?

andig avatar Mar 17 '22 20:03 andig

I've just started getting this issue and I believe it started right after I typo'd with 'd <dir_name>' instead of 'cd <dir_name>'. It's done it ever since (new iTerm2 sessions and a reboot)

braggy avatar Apr 13 '22 08:04 braggy

OK, so I've found the d function in ~/.oh-my-zsh/lib/directories.zsh:

function d () {
  if [[ -n $1 ]]; then
    dirs "$@"
  else
    dirs -v | head -n 10
  fi
}
compdef _dirs d

After giving the command dirs ~, this problem is now fixed for me!

Strangely, I can't seem to replicate the issue again with d <dir_name> though.

braggy avatar Apr 14 '22 09:04 braggy

It turns out the fix was also to have a symlink for python to python3, going by @djui's previous comment. It's now reproducable:

$ ll /usr/local/bin/python
/usr/local/bin/python -> /usr/local/bin/python3

$ rm /usr/local/bin/python
remove /usr/local/bin/python? y

$ d test
_alias_tips__preexec:34: command not found: python

$ ln -s /usr/local/bin/python3 /usr/local/bin/python
_alias_tips__preexec:34: command not found: python

$ d test
$ d test

braggy avatar Apr 14 '22 09:04 braggy