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
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.
-Linux — what the source command is doing> is not really for reloading the environment
Recommended Posts