6

I'm using Ubuntu 20.04 . I installed pyenv following this blog.

How to deactivate an acitvated pyenv - virtualenv I tried following

deactivate

pyenv-virtualenv: deactivate must be sourced. Run 'source deactivate' instead of 'deactivate'

source deactivate

pyenv-virtualenv: deactivate 3.6.9/envs/word_embedding

In ~/.bashrc I appended following

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
raviTeja
  • 338
  • 1
  • 7
  • 21
  • python already has venv package right? you don't have to install anything to make a virtual env. I use the command `python -m venv venv` to make virtual env with name venv in the current directory. – Atreyagaurav Oct 21 '20 at 12:51
  • @Atreyagaurav Is it possible to use multiple python version in venv – raviTeja Oct 21 '20 at 12:52
  • Seems possible. Whatever python version you used to make the venv will be used to make that venv. So, if you make venv from python 3.7 it'll have python 3.7 and if you make it from python 3.8 then it'll have python 3.8. (I haven't tried it, refer https://stackoverflow.com/questions/22681824/how-do-i-use-different-python-version-in-venv-from-standard-library-not-virtua) – Atreyagaurav Oct 21 '20 at 12:58
  • @ Atreyagaurav doesn;t installing differetn version of python affect ubuntu – raviTeja Oct 21 '20 at 13:04
  • No, as long as your main python is just one. the one which is symlinked to `python` command is the main one, you can install others in other command usually like `python2`, `python3.8` etc. If you look at your `python` command it is just a link to the recent version of python you installed. That's why it doesn't matter how many you have installed as long as the main one is same as that required by your system. – Atreyagaurav Oct 21 '20 at 14:46
  • for `pyenv` >= 2.0: change `eval "$(pyenv init -)"` to: `eval "$(pyenv init --path)"` – someguyinafloppyhat Apr 26 '22 at 16:11
  • Does this answer your question? [Deactivate pyenv in current shell](https://stackoverflow.com/questions/39348806/deactivate-pyenv-in-current-shell) – Hongbo Miao Dec 09 '22 at 07:45

2 Answers2

11

I had the same issue and pyenv deactivate was not working as well, instead use pyenv shell system.

From the pyenv shell docs:

This version overrides application-specific versions and the global version.

It sets $PYENV_VERSION to system, and does not affect a .python-version file present.

Later, if you want to undo this override, run pyenv shell --unset, which clears this $PYENV_VERSION environment variable.

Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
yudhiesh
  • 6,383
  • 3
  • 16
  • 49
1

pyenv global system worked for me.