pyenv-virtualenv: zsh: command not found: pyenv
My .zshenv
contains
export PYENV_ROOT="$HOME"/.pyenv
export PATH="$PYENV_ROOT"/bin:"$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
which works fine, however, if I simply add
eval "$(pyenv virtualenv-init -)"
I keep receiving the message
zsh: command not found: pyenv
Pyenv and pyenv-virtualenv work perfectly fine and if I enter exec "$SHELL"
the message goes away until I restart the terminal so I’m sure what the issue is.
I’m running Arch Linux, Zsh 5.4.2-1, tmux 2.5-3, termite 12-2, and the master branch of both pyenv and pyenv-virtualenv pulled today.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 36 (3 by maintainers)
Commits related to this issue
- Explicitly set PATH This is breaking some customers, who just copy paste these lines into their `*rc` file See https://github.com/pyenv/pyenv-virtualenv/issues/233#issuecomment-490677591 — committed to sean-smith/pyenv-installer by sean-smith 5 years ago
- Explicitly set .pyenv PATH This is breaking some customers, who just copy paste these lines into their `*rc` file See https://github.com/pyenv/pyenv-virtualenv/issues/233#issuecomment-490677591 — committed to sean-smith/pyenv-installer by sean-smith 5 years ago
- parent 772a5db31698325524e0046499130b127e2f5649 author Rahul <rahul@Rahuls-MacBook-Pro.local> 1604040420 +0800 committer Rahul <rahul@Rahuls-MacBook-Pro.local> 1604278976 +0800 parent 772a5db31698325... — committed to rahulraj1255/training_ansible by deleted user 4 years ago
I had this issue, after following https://github.com/pyenv/pyenv-installer
I changed my
~/.zshrc
from:To
My guess is that pyenv is being installed in a location that zsh doesn’t use by default (like /usr/local/bin). You probably have a line at the top of your .zshrc that looks like
export PATH=$HOME/bin:/usr/local/bin:$PATH
. Moving that line to the top of your .zshenv might fix the problem for you.In case of M1 users:
Pyenv gets installed to /opt/homebrew/Cellar/…
So running
pyenv which pyenv
showed me that I have pyenv installed to/opt/homebrew/Cellar/pyenv/2.0.6/libexec/pyenv
.Therefore, I added this to my
.zprofile
:eval "$(/opt/homebrew/Cellar/pyenv/2.0.6/libexec/pyenv init --path)"
instead ofeval "$(pyenv init --path)"
Works as expected.
Found this issue after installing via the pyenv-installer. (zsh on wsl ubuntu running in conemu) At first I added:
As mentioned in this thread. I got the following warning after restarting the shell:
After running pyenv init, it pretty much told me to add
eval "$pyenv init --path)" before the
eval “$(pyenv init -)”` command. Which I did and now it works with the following:However this means, that the pyenv-installer is currently broken. 😦
I have the same issue. My
~/.zshenv
file:The above fix didn’t work for me though. I used the following block in
~/.zshrc
instead:This is my
.profile
and.zprofile
settings which have solved the problem.profile
.zprofile
It
eval "$(pyenv virtualenv-init -)"
is showing errors like “zsh: command not found: pyenv”, it indicates thatpyenv-virtualenv-init
was called beforepyenv-init
. Sincepyenv-virtualenv
is heavily depending onpyenv
, it needs to be initialized afterpyenv
has initialized.Pasting your full zsh configurations (regard to pyenv/pyenv-virtualenv) here could help further investigation.
Works for me, thanks 😄
~
is not expanded within quotes.i had also some difficulties in windows WSL2 & zsh on ubuntu 20.04 I’ve removed the export command and that fixed it for me, now it looks like this at the end of my .zshrc