I am using zsh, and I have setup .zshrc following this answer. I can use pyenv in the terminal.
However, if I call pyenv activate from a script
#!/bin/zsh
pyenv activate konsole
it fails with
Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again.
What should I do?
It is necessary to access variables set up in .zshrc see this answer and so we need to use source <script-name>
So invoke the script using:
source <script-name>
and pyenv works