How to specify pyenv-virtual env using .file so that when I cd to a directory I automatically get correct pyenv and correct virtualenv selected.
Pyenv envaroment can be managed using .python-version
files.
First, install required python version using the command below example. You can find list of all available python versions with pyenv install --list
in your terminal.
Pyenv install 3.5.2
Next create pyenv virtual environment using following command. my-virtual-env-3.5.2 is the name of your environment
pyenv virtualenv 3.5.2 my-virtual-env-3.5.2
Next go to directory where you want to use this virtualenv and create .python-version
file
Edit your envaroment name and path to this file.
3.5.2/envs/my-virtual-env-3.5.2
In case you are not sure about the path and name of your environment you can list your environments running >
pyenv versions
In your terminal