Open krishnaghatti opened 5 years ago
Well, I have the same issue and then I wrote this plugin to solve that
https://github.com/alencarandre/pyenv-autoenv
It works fine with bash
. I ~dont~ didn't test it with zsh
.
Me: comes here not expecting a solution, and literally 5hrs earlier @alencarandre posts a solution ready for me to try out :-)
But of course it would be better if the advertised solution (as per the README) actually worked 🙂 so I'm going to hold out for that and just manually activate environments for now.
Just searched for it myself and it seems https://github.com/strokirk/pyenv-autoenv looks promising. The completion is a bit buggy, but at least it works.
cb@asterix:pts/1->/home/cb/tmp/autoenv/testfolder (0)
> pyenv autoenv
Using Python version 3.9.9
Downloading Python-3.9.9.tar.xz...
-> https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tar.xz
Installing Python-3.9.9...
Installed Python-3.9.9 to /home/cb/.pyenv/versions/3.9.9
Creating new virtualenv 'testfolder' with Python 3.9.9...
Looking in links: /tmp/tmppdz9eips
Requirement already satisfied: setuptools in /home/cb/.pyenv/versions/3.9.9/envs/testfolder/lib/python3.9/site-packages (58.1.0)
Requirement already satisfied: pip in /home/cb/.pyenv/versions/3.9.9/envs/testfolder/lib/python3.9/site-packages (21.2.4)
Setting local virtualenv 'testfolder'...
cb@asterix:pts/1->/home/cb/tmp/autoenv/testfolder (0)
> pyenv which python
/home/cb/.pyenv/versions/testfolder/bin/python
cb@asterix:pts/1->/home/cb/tmp/autoenv/testfolder (0)
> cd ..
cb@asterix:pts/1->/home/cb/tmp/autoenv (0)
> pyenv which python
/home/cb/.pyenv/versions/3.10.2/bin/python
cb@asterix:pts/1->/home/cb/tmp/autoenv (0)
> cd testfolder
cb@asterix:pts/1->/home/cb/tmp/autoenv/testfolder (0)
> pyenv which python
/home/cb/.pyenv/versions/testfolder/bin/python
cb@asterix:pts/1->/home/cb/tmp/autoenv/testfolder (0)
> cat .python-version -p
testfolder
Hello all,
I am trying the autoenable of venv part. I have the
eval "$(pyenv virtualenv-init -)"
set in my shell rc file and also have the venv in the.python-version
file of the directory. But then I try tocd
to the dir, the prompt does not get set as expected.When I manually run the
activate
step I do get the promptBasically the venv is active at this point and if I open a new terminal to the same dir, the prompt is not set and I am not sure if I am running in the
venv
and I get the bellow message along with the expected pip packages installed as per the project.The behaviour is some times not consistent like in the case of a new venv setup the shell prompt does not change and its confusing at times
I am using a mac os 10.14.3 and zsh (with oh-my-zsh plugin). Am I missing something elementary? Please advice.