You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pyenv do as an easier alternative to PYENV_VERSION= pyenv exec #1932
Make sure no duplicated issue has already been reported in the pyenv issues. You should look for closed issues, too.
Make sure you are not asking us to help solving your specific issue.
GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.
Make sure your problem is not derived from packaging (e.g. Homebrew).
Please refer to the package documentation for the installation issues, etc.
Make sure your problem is not derived from plugins.
This repository is maintaining pyenv and the default python-build plugin only. Please refrain from reporting issues of other plugins here.
Description
Quite often, I need to run a command against a specific installed version statelessly (i.e. without affecting the current environment).
The current way to do that is PYENV_VERSION=<version> pyenv exec <command>, or PYENV_VERSION=<version> <command> if the executable is a shim
All other ways are stateful:
pyenv local/global
pyenv shell
After seeing a very convenient and quick-to-type rvm do command for that in RVM, I just don't want to type all the above each time anymore! 😄
Reacted by DeepUpSonnemann, Bence Ferdinandy, Jim Conner, Andreas Motl, Gary Oberbrunner, Kent Ross, Lewis A. Marshall, Daniele Parmeggiani, Eytan Hanig, Mieszko Bańczerowski and 4 more
I'm here because I was looking for a solution to the exact same problem. I've got a bunch of pip-installed commands and I'm trying to find a way to work in a directory which has a .python_version already without having to pip-install everything for that specific version of python.
A pyenv do command sure would make life simpler for me.
I wrote pyenv-do plugin as a patched alternative for pyenv exec. This approach would compatible with native exec command but still need hack for the completion part.
I wrote pyenv-do plugin as a patched alternative for pyenv exec. This approach would compatible with native exec command but still need hack for the completion part.
Not sure why the environment argument is optional. The entire purpose of do is to have that extra argument. If you don't need it, you have exec (or just running the command if it's a shim).
@native-api I'd like to pick this up. I'm thinking pyenv do <version> <command> that just sets PYENV_VERSION and calls pyenv exec, with the version required. Does that work or is it better having it as an option on exec?
I'm thinking pyenv do <version> <command> that just sets PYENV_VERSION and calls pyenv exec, with the version required. Does that work or is it better having it as an option on exec?
As per the discussion above, pyenv do is a clear winner.
IMO documenting it as equivalent/alias to PYENV_VERSION=<version> pyenv exec is enough.
Activity
StoneMoe commentedon Oct 12, 2021
If you are using
fishshell, and you want this feature RIGHT NOW:~/.config/fish/config.fish
~/.config/fish/completions/pyenvdo.fish (Optional for auto-complete)
now you can
jimconner commentedon Oct 25, 2021
I'm here because I was looking for a solution to the exact same problem. I've got a bunch of pip-installed commands and I'm trying to find a way to work in a directory which has a .python_version already without having to pip-install everything for that specific version of python.
A
pyenv docommand sure would make life simpler for me.+1 for this feature request.
kotokaze commentedon Oct 5, 2022
I wrote pyenv-do plugin as a patched alternative for
pyenv exec. This approach would compatible with nativeexeccommand but still need hack for the completion part.1Mark commentedon May 20, 2023
pyenv exec ... -- 3.11.3would suit the current flag better?native-api commentedon May 20, 2023
Not sure why the environment argument is optional. The entire purpose of
dois to have that extra argument. If you don't need it, you haveexec(or just running the command if it's a shim).mrmeszaros commentedon Jul 3, 2023
I think the idea would be able to replace exec, and not to need two commands for doing one thing.
However, ideally I think this could be merged as an option named
--env=or--with=into theexeccommand.macayu17 commentedon Nov 14, 2026
@native-api I'd like to pick this up. I'm thinking
pyenv do <version> <command>that just setsPYENV_VERSIONand callspyenv exec, with the version required. Does that work or is it better having it as an option on exec?native-api commentedon Nov 14, 2026
As per the discussion above,
pyenv dois a clear winner.IMO documenting it as equivalent/alias to
PYENV_VERSION=<version> pyenv execis enough.native-api commentedon Nov 14, 2026
We can discuss adding
--envor something topyenv execas a separate idea and see how much traction it gets.macayu17 commentedon Nov 16, 2026
Thanks, I'll put up a PR.