Issue
I am using a pyenv
guide from here Managing Multiple Python Versions With pyenv
I have already created a 3.6.7 version:
13:24:51/hercl $pyenv versions
system
* 3.6.7 (set by /Users/steve/.pyenv/version)
I made 3.6.7 global:
pyenv global 3.6.7
But the python being used is the system version
$python -V
Python 3.9.9
Also there are many references to pyenv activate
but that command does not exist??
$pyenv commands
--version
commands
completions
exec
global
help
hooks
init
install
local
prefix
rehash
root
shell
shims
uninstall
version
version-file
version-file-read
version-file-write
version-name
version-origin
versions
whence
which
So how is the 3.6.7 version to be activated?
Update. here is how I installed and enabled pyenv
:
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
Also do I really need to uninstall the python versions already installed via brew
? installing-pyenv-on-macos
Solution
While I had installed pyenv
I had missed installing pyenv-virtualenv
.
brew install pyenv-virtualenv
The following had already been added to ~/.bashrc
but the second line had not been working. it does now
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
And pyenv activate
now runs fine
$pyenv activate 3.6.7
pyenv-virtualenv: virtualenv `/Users/steve/git/hercl/.venv' is already activated
Wow that was a confusing problem.
Update An additional step is needed: to manually add the $HOME/.pyenv/shims
directory to the PATH. So now the last three lines of my ~/.bash_profile
are:
export PATH=.:$HOME/.pyenv/bin:$HOME/.pyenv/shims:/opt/brew/bin:/opt/homebrew/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/bin
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Answered By - WestCoastProjects Answer Checked By - Katrina (WPSolving Volunteer)