A Python version control tool.
There are many articles on how to use pyenv, ** ・ In 3.7 or later, an error occurs during installation ** ** ・ The settings are not reflected at startup only with .bash_profile ** Therefore, I posted this article as a memorandum.
・ RaspberryPi connected to the network (RaspberryPi3 ModelB is used this time)
I referred to here.
Install pyenv to update the Python version. I referred to here. (If you have already installed it, please skip it)
-Installation of required packages
sudo apt install git openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev
・ In 3.7 or later, an error will occur if the following packages are not installed.
sudo apt install libffi-dev
-Copy pyenv from Github
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
-Edit home / [username] /.bash_profile (create if not)
.bash_profile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
・ After restarting Raspberry Pi, check the version of pyenv
pyenv --version
Success if the version is displayed like "pyenv 1.2.18-8-g5e8719ab"
** * When the version is not displayed ** Add the following contents to home / [user name] /. profile (Same content as in .bash_profile)
.profile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Reboot and run "pyenv --version" and you should see the version
-Display a list of installable versions
pyenv install --list
-Install the desired version For example, if you want to install 3.7.6,
pyenv install 3.7.6
・ Version change
pyenv global 3.7.6
・ Check if the version has been updated
python --version
python3 --version
Both are successful if they are the updated version (3.7.6)
Recommended Posts