I often want to start a jupyter notebook in a specific conda environment. In order to speed up that process, I add the two commands into one powershell script, like so:
# conda_notebook.ps1
conda activate my_env
jupyter notebook --ServerApp.root_dir C:\Users\me\my-notebooks
This works perfectly fine when executing in a anaconda powershell. I also have pyenv-venv virtual environments in my Windows installation for cases, where I have trouble with conda, e.g., python versions not supported in conda (yet?). The approach
# pyenv_notebook.ps1
pyenv-venv activate my_env2
jupyter notebook --ServerApp.root_dir C:\Users\me\my-other-notebooks
does not work, as pyenv-venv activate my_env2 spawns a new shell. Hence, the second argument is not executed immediately, but only once I exit the newly spawned shell. Then, it fails as there is no jupyter notebook command around in the previous shell. The pyenv suit has a pyenv shell command that changes the current shell instead of spawning a new one. It does not exist for pyenv-venv, unfortunately.
However, there must be a way of piping the second command into the first, so that the second command is actually executed in the newly spawned shell. How do I do that?
EDIT1:
"jupyter notebook --ServerApp.root_dir D:\drescherlab\misc-win" | pyenv-venv activate dev3.12.3
and
ECHO "jupyter notebook --ServerApp.root_dir D:\drescherlab\misc-win" | pyenv-venv activate dev3.12.3
do not work. I guess we can expect that, as the pyenv-venv activate ... does not expect a piped in value. The command jupyter notebook ... has to be executed only after the command pyenv-venv activate ... has spawned the new shell.