zsh-quickstart-kit icon indicating copy to clipboard operation
zsh-quickstart-kit copied to clipboard

(anon):16: command not found: python

Open RonanJackson opened this issue 2 years ago • 15 comments

Describe the bug After installing MacOS 12.3 Monterey I get the error every time I boot a fresh terminal session. Running on a MacBook Pro M1.

(anon):16: command not found: python

Expected behavior No errors

Additional context This only started since updating the OS to 12.3. I have Pyenv Python installed.

I have eval "$(pyenv init --path)" in my 001-config file which evaluates the keyword python after my session has booted, but the error appears before this command is presumably initiated.

I have tried running zqs update with no luck.

RonanJackson avatar Mar 21 '22 11:03 RonanJackson

I'm on 12.3 but not seeing this yet. I have python3 installed via brew, though. I'll take a look but realistically not until the weekend

unixorn avatar Mar 21 '22 19:03 unixorn

Problem seems to be at ohmyzsh python plugin

https://github.com/ohmyzsh/ohmyzsh/issues/10469

realsuiciniv avatar Mar 24 '22 18:03 realsuiciniv

Thanks for tracking this down, @realsuiciniv

Given that this is an upstream problem I'm not sure what I can do to fix it other than remove the python plugin from the default list when python isn't found in the user's $PATH.

That seems problematic though - either they silently lose functionality they're used to using, or the quickstart starts spamming them with a warning every time they open a new terminal window.

@RonanJackson, @realsuiciniv - which do you think is the least annoying workaround?

unixorn avatar Mar 25 '22 15:03 unixorn

I could hack something that looks for a sentinel file and only spams if the sentinel is missing, but I don't want to pollute users' home directories more than I already am.

unixorn avatar Mar 25 '22 15:03 unixorn

I'm confused why my Intel machine doesn't seem to have this issue but my M1 does, is this related?

RonanJackson avatar Mar 25 '22 17:03 RonanJackson

What do you think of checking for python, and if it's not in $PATH, aliasing it to python3 if python3 is in $PATH?

And thanks for the find, @realsuiciniv.

unixorn avatar Apr 30 '22 15:04 unixorn

I'm a little hesitant to step on people's environments like that by default. Maybe have it puke up a warning, and add a zqs command to enable setting the alias.

unixorn avatar Apr 30 '22 15:04 unixorn

i solved this on my system using sudo apt install -y python-is-python3

DuckyBlender avatar May 22 '22 17:05 DuckyBlender

i solved this on my system using sudo apt install -y python-is-python3

This is a Mac specific issue, not Ubuntu/Debian.

I've tried 'alias python=/usr/bin/python3' in .zshrc.d, but the plugins are loaded before so it doesn't seem to help.

is there a place to set alias before .zshrc is loaded? Adding to .zshenv also doesn't work.

defcon79 avatar May 26 '22 21:05 defcon79

I'll make a .zshrc.preplugins.d.

unixorn avatar Jun 15 '22 19:06 unixorn

@defcon79 / @RonanJackson, would you mind testing the add-zshrc.pre-plugins.d-handling branch and see if that allows you to work around the issue?

unixorn avatar Jun 15 '22 19:06 unixorn

I don't see this branch, looks like you deleted after merging to main. Doesn't seem to have fixed anything when I updated zsh from the main branch. Anything you would like me to try?

RonanJackson avatar Jun 19 '22 17:06 RonanJackson

@unixorn I have tested zshrc.pre-plugins.d, and creating file with something like this

export PATH="/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/libexec/bin:$PATH"

solves the issue.

kpostekk avatar Jun 20 '22 07:06 kpostekk

I'm still seeing this issue while using the above suggestions. I'm on Monterey 12.4. Using python3 from brew.

In this directory (~/.zshrc.pre-plugins.d) I created a file call 001-update-python

Put this entry: export PATH="/usr/local/Cellar/[email protected]/3.9.13_1/bin:$PATH"

Python executes correctly but I still get the error.

(anon):16: command not found: python (anon):16: command not found: python (anon):16: command not found: python

donimos avatar Jul 14 '22 00:07 donimos

In this directory (~/.zshrc.pre-plugins.d) I created a file call 001-update-python Remove numbers from the beginning. Should fix the issue.

Screenshot 2022-07-14 at 17 58 29

kpostekk avatar Jul 14 '22 15:07 kpostekk

@jmcdowell, @kpostekk, @realsuiciniv, @RonanJackson, @defcon79

#220 should fix things - if you still have issues, we can re-open this.

unixorn avatar Sep 18 '22 15:09 unixorn

I will test it soon

kpostekk avatar Sep 18 '22 15:09 kpostekk

I'm still running into this issue after #220 - the error is occurring during the loading of the zsh-completion-generator plugin

fwwieffering avatar Sep 20 '22 01:09 fwwieffering

That's weird - zsh-completion-generator is only supposed to load when you explicity use it.

What does which python show on your machine? And please paste the error message you're seeing.

If you set GENCOMPL_PY=python3 in a file in ~/.zshrc.pre-plugins.d do you still see the error?

unixorn avatar Sep 20 '22 03:09 unixorn

The error is the same as mentioned in this ticket

Creating a zgenom save
(anon):16: command not found: python
(anon):16: command not found: python

What does which python show on your machine?

The alias you added in #220 is getting set

which python
python: aliased to python3

If you set GENCOMPL_PY=python3 in a file in ~/.zshrc.pre-plugins.d do you still see the error?

This fixes the error!

fwwieffering avatar Sep 20 '22 13:09 fwwieffering

Thanks!

I'll add a workaround that sets GENCOMPL_PY if it's unset and python is not in $PATH, then unsets it after loading all the plugins.

unixorn avatar Sep 20 '22 13:09 unixorn

@fwwieffering - could you please comment out your GENCOMPL_PY setter, then zqs selfupdate and confirm this fixed it for you?

Hopefully #223 fixed the zsh-completions-plugin special case.

Thanks!

unixorn avatar Sep 20 '22 14:09 unixorn

@unixorn everything is hunky dory. Thanks for the fix!

fwwieffering avatar Sep 20 '22 14:09 fwwieffering

Thanks for checking, I appreciate it.

unixorn avatar Sep 20 '22 14:09 unixorn

Everything seems to work for me now, thanks!

RonanJackson avatar Sep 20 '22 18:09 RonanJackson