This is an article about changing the version of python. Some tools such as GCP tools (2.7 series) have a python version specified, so you will need to switch when using them. This time, how to switch versions using a tool called pyenv I will introduce the method by anaconda.
//Install pyenv
$ brew install pyenv
//Reference of installable version
$ pyenv install -l
//Install the version you want
$ pyenv install 2.7.16
//Check the version at hand
$ pyenv versions
//Version change: local for local, global for global
$ pyenv local 2.7.16
$ pyenv global 2.7.16
If the version does not change, check below If you are using anaconda for version control, proceed to the next step.
If you already have anaconda etc. installed The version is not changed in pyenv because the reference destination is different. The conda environment is displayed at the beginning of the prompt
//Creating anaconda environment
conda create -n py27 python=2.7 anaconda
//Environmental confirmation at hand of anaconda
conda info -e
//Set the environment to use
conda activate py27
//Exit the conda environment(Return to base)
conda deactivate
The usability is similar, You will create and use a version and environment at hand.
In creating this article, I referred to the following article.
Use different python versions in Anaconda https://qiita.com/hurts14/items/116ef0e332e159a51c4f
Recommended Posts