DEV Community

Reishi Mitani
Reishi Mitani

Posted on

1

Creating a Python3 Environment Using Pyenv in EC2

First, you need git.

$ sudo yum install git
// type yes to all questions
$ git version
git version 2.23.3
Enter fullscreen mode Exit fullscreen mode

Then install pyenv by cloning from GitHub.

git clone https://github.com/yyuu/pyenv.git ~/.pyenv
Enter fullscreen mode Exit fullscreen mode

Create the paths for pyenv.

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

// Check if the paths are created correctly.
$ pyenv -v
pyenv 1.2.20-5-g1ec3c6f1
Enter fullscreen mode Exit fullscreen mode

Install the necessary dependencies.

sudo yum install gcc zlib-devel bzip2 bzip2-devel readline readline-devel sqlite sqlite-devel openssl openssl-devel libffi-devel -y
Enter fullscreen mode Exit fullscreen mode

Install python.

$ pyenv install 3.7.0
// This will take several minutes to complete
Enter fullscreen mode Exit fullscreen mode

Choose 3.7.0 as the global version.

$ pyenv global 3.7.0
$ pyenv rehash
$ python --version
3.7.0
Enter fullscreen mode Exit fullscreen mode

References

EC2サーバにPython3環境構築
pyenvで3.7系のインストールに失敗したときのメモ

Sorry, only Japanese versions are available.

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay