Method of Installing pyenv under Linux

  • 2021-07-03 01:02:16
  • OfStack

Precondition

git required

Installation steps

1. Cloning pyenv from a remote repository

Clone pyenv using the following command:


git clone https://github.com/yyuu/pyenv.git ~/.pyenv 

2. Configure environment variables

Use the following three commands in turn to configure the environment variables:


echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

Or go directly to the file and add at the end:


vim ~/.bash_profile
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)" 

3. Use environment variables

Re-execute the configuration file modified in step 1 using the source command:


source ~/.bash_profile

At this point, pyenv is installed.

You can view the installed version of pyenv using the following command:


[root@server1 local]# pyenv -v
pyenv 1.2.13-14-gecd67c8

Summarize


Related articles: