activate venv with pyenv

Viewed 30400

I followed this guide to install pyenv in order to manage all python versions I have installed on my Mac. However, it is not clear to me what the pyenv global 3.7.3 command does and how I can activate a venv that uses python 3.7. If I type:

$ pyenv version
3.7.3

But apparently this is not enough to activate the venv?

3 Answers

list python versions in terminal:

$ pyenv install --list | grep " 3\.[678]"

Install Python version if not in list:

$ pyenv install 3.8.6

Create virtual env with python version:

$ pyenv virtualenv 3.8.6 project1

List versions of virtual environments:

$ pyenv versions

Activate a virtual version:

pyenv activate project1

pyenv global 3.7.3

sets the global version of Python to 3.7.3. It means that if you decide to use Python on your machine without using a virtual environment, then the version 3.7.3 is going to be used as a default.

2) In order to activate the virtual environment use

pyenv activate <name>

and to deactivate the virtual environment use

pyenv deactivate

For more details check this link https://github.com/pyenv/pyenv-virtualenv

If you're using virtualenv, just type

pyenv virtualenvs

Then to activate a particular env

pyenv activate [name]

Related