Drishti
Drishti

Reputation: 43

How to activate a pyenv-venv environment?

I can't seem to activate a virtual environment that I have created previously. I've tried 'source animalai/bin/activate'. The error message I receive is that such a directory does not exist.

I've listed the code below for when I first created the virtual environment (part of my history) — I've made some silly errors but eventually created the environment and ran a program on it ('animalai').

brew update

brew install pyenv


clear

install pyenv

clear  

pip install pyenv

pyenv virtualenv 3.6.0  animalai

pyenv virtualenv 3.6.0  animalai

eval "$(pyenv init -)"

eval "$(pyenv init -)"

pyenv

pyenv update

curl https://pyenv.run | bash

source animalai/bin/activate

source animalai/bin/activate

source venv/bin/activate

pip install animalai

Am I doing something wrong here? I expected my environment to load. I was definitely in the virtual environment previously (before I deactivate it) - there was a (animalai) beside (base).

Upvotes: 0

Views: 3466

Answers (2)

L Miller
L Miller

Reputation: 21

'pyenv shell myenv' worked to activate, but deactivate was still unclear. I found this post recommending 'pyenv shell system' which seems to work. However the 'system' python may not be the one you want. Recommended to look at 'pyenv versions' before selecting which shell to move to. Essentially there is no deactivate, just moving to a different shell. But this may work in terms of homebrew which should be run from python and not a virtual environment (pyenv being python).

How to deactivate pyenv virtual environment

The error message for 'deactivate' recommended 'source deactivate', but neither of these worked for me.

Upvotes: 1

Josir
Josir

Reputation: 1644

You have to replace source command with

pyenv shell animalai

Upvotes: 2

Related Questions