Installing pyenv in Amazon Linux EC2
Please find the steps below:
- Check out pyenv where you want it installed. A good place to choose is
$HOME/.pyenv
(but you can install it somewhere else).
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
2. Define environment variable PYENV_ROOT
to point to the path where pyenv repo is cloned and add $PYENV_ROOT/bin
to your $PATH
for access to the pyenv
command-line utility.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
3. Add pyenv init
to your shell to enable shims and autocompletion. Please make sure eval "$(pyenv init -)"
is placed toward the end of the shell configuration file since it manipulates PATH
during the initialization.
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
4. Restart your shell so the path changes take effect. You can now begin using pyenv.
exec "$SHELL"
5. Install Python build dependencies before attempting to install a new Python version.
yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel
6. Install Python versions into $(pyenv root)/versions
. For example, to download and install Python 2.7.8, run:
pyenv install 2.7.8
I hope this helps.
To know more, please reach out to the source page — https://github.com/pyenv/pyenv#basic-github-checkout
Thank you!