Procedure from uninstalling pyenv to installing again (anaconda)

Preferences for pyenv ~ anaconda

In this article, I would like to write a series of flow from uninstallation to installation when a problem occurs in anaconda etc.

Environment used

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.2
BuildVersion:   19C57

uninstall pyenv

Follow the steps below to uninstall

--Uninstall pyenv-virtualenv

$ brew uninstall pyenv-virtualenv
Uninstalling /usr/local/Cellar/pyenv-virtualenv/1.1.3... (20 files, 62.2KB)

--Uninstall pyenv

$ brew uninstall pyenv
Uninstalling /usr/local/Cellar/pyenv/1.2.14_1... (656 files, 2.4MB)

--Delete pyenv directory

$ rm -rf $(pyenv root)

This is the same as $ rm -rf ~ / .pyenv

Install pyenv again

Install pyenv with the following command

$ brew install pyenv

Addition to .bash_profile

Execute the following command

$ 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

Install the python environment you want to use on pyenv

--Get a list of python versions you can install --A list of installable versions is displayed as follows.

$ pyenv install --list
Available versions:
  2.1.3
  2.2.3
  2.3.7
  2.4.0
  ...
(abridgement)
  ...
  3.0.1
  3.1.0
  3.1.1
  3.1.2
  ...
(abridgement)
  ...  
  3.6.8
  3.6.9
  3.7.0
  3.7-dev
  3.7.1
  3.7.2
  3.7.3
  3.7.4
  3.7.5
  3.7.5rc1
  3.8.0
  3.8-dev
  3.9-dev
  activepython-2.7.14
  activepython-3.5.4
  activepython-3.6.0
  anaconda-1.4.0
  anaconda-1.5.0
  anaconda-1.5.1
  anaconda-1.6.0
  anaconda-1.6.1
  anaconda-1.7.0
  ...
(abridgement)
  ... 
  anaconda3-5.1.0
  anaconda3-5.2.0
  anaconda3-5.3.0
  anaconda3-5.3.1
  anaconda3-2018.12
  anaconda3-2019.03
  anaconda3-2019.07
  anaconda3-2019.10
  ...
(abridgement)
  ... 

--This time, I want to use the anaconda environment, so specify the version you want from the above list. --I want to use anaconda, so execute the following command

$ pyenv install anaconda3-2019.10

If you want normal python, just do $ pyenv install 3.7.5

Switch the environment of pyenv

--Get a list of available python environments

$ pyenv versions

--Python is out of date immediately after installation

$ python --version
Python 2.7.15

--Check the available python version

$ pyenv versions
  system
* anaconda3-2019.10 (set by /Users/******/.pyenv/version)

--Specify the entire python version with the following command

$ pyenv global anaconda3-2019.10

--Check the version of python you are using --OK if it is set to the specified version

$ python --version
Python 3.7.4

Delete the originally used anaconda

--When the newly installed version is ʻanaconda3-2019.10`, the past version remains as follows.

$ cd ~/.pyenv/versions/
$ ls
anaconda3-2019.10/ anaconda3-5.3.1/

--If you were originally using the environment ʻanaconda3-5.3.1, execute the following command. --As it is, even if you execute the rm command, it cannot be deleted with authority, so execute it with sudo`.

$ sudo rm -rf ~/.pyenv/versions/anaconda3-5.3.1/

Make sure python is called correctly

$ vim /etc/paths

--The contents of / etc / paths look like this. Priority is given from the top.

 1 /usr/local/bin
 2 /usr/bin
 3 /bin
 4 /usr/local/sbin
 5 /usr/sbin
 6 /sbin

that's all

Recommended Posts

Procedure from uninstalling pyenv to installing again (anaconda)
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
[Introduction] From installing kibana to starting
How to install Anaconda with pyenv
Change the active version in Pyenv from anaconda to plain Python
[For beginners] What to do after installing Anaconda
How to operate Linux from the outside Procedure
From Python environment construction to virtual environment construction with anaconda
Sum from 1 to 10
pyenv + anaconda + python3
From setting up Raspberry Pi to installing Python environment
Steps from installing Django to displaying an html page
Procedure to install TensorFlow in fish shell environment (Anaconda 4.0.0)
Procedure to exe python file from Ubunts environment construction