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

Activate virtualenv: Example

Open pgy866 opened this issue 1 year ago • 0 comments

Activate virtualenv Some external tools (e.g. jedi) might require you to activate the virtualenv and conda environments.

If eval "$(pyenv virtualenv-init -)" is configured in your shell, pyenv-virtualenv will automatically activate/deactivate virtualenvs on entering/leaving directories which contain a .python-version file that contains the name of a valid virtual environment as shown in the output of pyenv virtualenvs (e.g., venv34 or 3.4.3/envs/venv34 in example above) . .python-version files are used by pyenv to denote local Python versions and can be created and deleted with the pyenv local command.

  • For example::The virtual space name is my-virtual-env-2.7.10,Create a file named .python-version in the virtual space folder my-virtual-env-2.7.10, and add the text of the micro virtual space name my-virtual-env-2.7.10

echo "my-virtual-env-2.7.10" >> $HOME/.pyenv/versions/2.7.10/envs/my-virtual-env-2.7.10/.python-version

You can also activate and deactivate a pyenv virtualenv manually:

pyenv activate <name>
pyenv deactivate

pgy866 avatar Jan 03 '23 15:01 pgy866