Shell script to build pyenv environment on ubuntu in one shot

Conclusion

Python in the pyenv environment, which I use very often. A simple script to automate its deployment. I couldn't find an article in the format of sh file, so I posted it for myself. I will put the script body immediately. However ...

※Caution※ Let's run it with $ source pyenv_setup.sh. --You can't use sh or ./. The source running in the script doesn't work and the pyenv path doesn't go through. --For the reason, click here [Other articles](https://qiita.com/YumaInaura/items/00437e6ab14d96adb71f#-source-%E3%81%A8--bash-%E3%81%AE%E9%81% Please refer to 95% E3% 81% 84).

pyenv_setup.sh


#Introducing dependent modules
sudo apt install -y build-essential libffi-dev libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
# libssl-dev -> openssl
# libbz2-dev -> sqlite3
# libreadline-dev -> bz2
# libsqlite3-dev -> readline

#Download pyenv body
sudo apt install -y git
git clone https://github.com/pyenv/pyenv.git ~/.pyenv

# .bashrc update
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
pyenv -v #Check if pyenv was installed

#python installation
pyenv install 2.7.0
pyenv install 3.6.0
pyenv versions

#Select version to use
pyenv global 3.6.0
pyenv versions

background

If you use it often, it would be nice to be able to build an environment with just one shot. In particular, I often build and destroy ubuntu with vagrant, build and destroy it, and so on. Even in such a case, if you write to read this script in Vagrantfile, it is easy to build a python environment in one shot when vagrant up is done.

reference

-Linux — what the source command is doing> is not really for reloading the environment

Recommended Posts

Shell script to build pyenv environment on ubuntu in one shot
Build python environment with pyenv on EC2 (ubuntu)
[Latest] How to build Java environment on Ubuntu
How to build a new python virtual environment on Ubuntu
How to convert 0.5 to 1056964608 in one shot
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Method to build Python environment in Xcode 6
Build Python3 and OpenCV environment on Ubuntu 18.04
Steps to install Python environment on Ubuntu
[Ubuntu] How to execute a shell script
Build WordPress on CentOS 8 in LAMP environment
Introduction to docker Create ubuntu environment in ubuntu
Try to build python and anaconda environment on Mac (by pyenv, conda)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Install python package in personal environment on Ubuntu
Build a Kubernetes environment for development on Ubuntu
[TF] How to build Tensorflow in Proxy environment
From nothing on Ubuntu 18.04 to setting up a Deep Learning environment in Tensor
I want to use Python in the environment of pyenv + pipenv on Windows 10
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Procedure to install TensorFlow in fish shell environment (Anaconda 4.0.0)
How to build a Django (python) environment on docker
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Build a Python development environment using pyenv on MacOS
Installing pyenv on ubuntu 16.04
Memo A beginner tried to build a Java environment and Japaneseize it on Ubuntu 18.04.2 LTS.
How to build a Python environment on amazon linux 2
When I tried to build a Rails environment on WSL2 (Ubuntu 20.04LTS), I stumbled and fell.
How to manage Python minor version (build virtual environment) on Windows (without Pyenv or WSL)
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
How to adapt multiple machine learning libraries in one shot
Build an Ubuntu python development environment on Google Cloud Platform
How to use VS Code in venv environment on windows
Introducing Kaggle's Docker Image on Windows to build an environment
A note on how to load a virtual environment in PyCharm
Until building a Python development environment using pyenv on Ubuntu 20.04
Build python3 environment with ubuntu 16.04
Build Python environment on Windows
Byobu crashes in pyenv environment
Build python environment on windows
Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
How to deal with python installation error in pyenv (BUILD FAILED)
Build a Selenium environment on Amazon Linux 2 in the shortest time
# 3 Build a Python (Django) environment on AWS EC2 instance (ubuntu18.04) part2
I just wrote a script to build Android on another machine
How to use python put in pyenv on macOS with PyCall
Build Python environment on Ubuntu (when pip is not the default)
How to determine if a shell script was started in bash
How to calculate "xx time" in one shot with Python timedelta
A story when a beginner gets stuck trying to build a vim 8.2 + python 3.8.2 + lua plugin environment on Ubuntu 18.04.4 LTS
Building a Python environment on Ubuntu
Modify Ubuntu tofu to Japanese environment
Automate environment construction with Shell Script
From Ubuntu 20.04 introduction to environment construction
Build a python3 environment on CentOS7
How to install Go on Ubuntu
Environment construction of "Tello_Video" on Ubuntu
OpenCV3 & Python3 environment construction on Ubuntu
Build wxPython on Ubuntu 20.04 on raspberry pi 4