pyenv-virtualenv icon indicating copy to clipboard operation
pyenv-virtualenv copied to clipboard

` pyenv [ shell | local ] new-env ` is interfered by the previously activated virutalenv.

Open hongyi-zhao opened this issue 4 years ago • 2 comments

Hi,

I noticed that when activating some virtualenv with the following command:

$ pyenv [ shell | local ] new-env

The newly activated virtualenv maybe interfered by the previously activated virtualenv, say, named as old-env. To avoiding this problem, the following commands combinations need to be used:

$ pyenv [ shell | local ] --unset
$ pyenv [ shell | local ]  new-env

So, it seems the above commands combinations should be defined for activating new virtualenvs.

Regards, HY

hongyi-zhao avatar May 06 '20 10:05 hongyi-zhao

Can you please expound a little bit on what you mean by maybe interfered by the previously activated virtualenv ?

More precisely, can you please tell us what led you to pyenv shell --unset and then pyenv shell new-env while working on some foo.py or some other project?

wadkar avatar May 10 '20 15:05 wadkar

I use pyenv to install anaconda3-2020.02 and then based on the anaconda installed there I created two envs with conda create located at ~/.pyenv/versions/anaconda3-2020.02/envs/test1 and ~/.pyenv/versions/anaconda3-2020.02/envs/test2. And then I symlinked both test1 and test2 to the following location: ~/.pyenv/versions/. This way, I can use the symlinked names to manage these envs.

After the above steps, I created some customized scripts under the test1/etc/conda/(de)activate.d which set and unset some alias respectively. At this moment, if I activate test2 whith pyenv shell test2 and then activate test1 with pyenv shell test1, the command defined by alias for test1 will be set. But when I leave the test1 env, I found that the alias not been unset. Bur if I firstly issue the pyenv shell --unset command, the problem will be solved.

Regards

hongyi-zhao avatar May 11 '20 04:05 hongyi-zhao