I installed pyenv and pyenv-virtualenv with brew too and had the same issue.
It's easy to solve after you know exactly what to do:
1- You need to know what shell interpreter you are using. Direct quoting from the https://support.apple.com/en-us/HT208050
By default, your Mac uses either zsh or bash as the command-line
interpreter for the login shell and interactive shell:
- zsh (Z shell) is the default shell for all newly created user accounts, starting with macOS Catalina.
- bash is the default shell in macOS Mojave and earlier.
And of course, each interpreter is using different files for environment variables, like PATH, JAVA_HOME etc.
bash is using $HOME/.bash_profile and $HOME/.bashrc, while zsh is using $HOME/.zprofile and $HOME/.zshrc
2- After installing pyenv and installing the python version which you want to use (e.g. pyenv install 3.y), open the /.bash_profile or /.zprofile file wrt your interpreter.
Note1: I'm using bash interpreter and my $HOME/.bashrc file is empty. So I don't know what happens whether any PATH declaration in the /.bashrc would affect the /.bash_profile declarations or not. You may need to check this.
3- pyenv creates $HOME/.pyenv/shims directory and uses this to switch python versions that you installed.
So you just need to add the following line to the bottom (not necessarily to the very bottom of the file. You just need to go to the end of all PATH declarations.)
export PATH=$HOME/.pyenv/shims:$PATH
Note2: "$HOME/.pyenv/shims" MUST be at the beginning of the PATH variable. Because all the paths are read from left to right order by the interpreter. So be careful adding new paths to the PATH variable in the future.
Note3: There are two commands that sets python version. One is "pyenv global #python_version_here#" and the other is "pyenv local #python_version_here#". Under a directory, hierarchically "local" command is top of "global" one. So, if you run the "local" command under $HOME directory, you cannot change the global python version with the "global" command. In that case, either
1- You can continue to use "local" command under the $HOME directory
2- Delete $HOME/.python-version file and return to "global" setting
This is my shell output to show this hierarchy:
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv global system
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv versions
* system (set by /Users/ozgurcengelli/.pyenv/version) #look the path
3.6.15
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv local system
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv versions
* system (set by /Users/ozgurcengelli/.python-version) #look the path
3.6.15
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv global 3.6.15
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv versions
* system (set by /Users/ozgurcengelli/.python-version) #look the path
3.6.15
Ozgurs-MacBook-Pro:~ ozgurcengelli$ rm $HOME/.python-version
Ozgurs-MacBook-Pro:~ ozgurcengelli$ pyenv versions
system
* 3.6.15 (set by /Users/ozgurcengelli/.pyenv/version) #look the path