MacOS Catalina 10.15.1
Originally, python2 was included as standard on Mac, and I used to write python3 code without worrying about it, but when I tried to use jupyter notebook the other day, when I tried to create a new file in jupyter notebook, only python2 I felt like I was in trouble because I couldn't make a choice. After investigating, it seems that it can be fixed unexpectedly easily, so I will summarize it
First, install ipykernel
python3 -m pip install ipykernel
Then run the following command
python3 -m IPython kernelspec install-self
This alone solved it
While investigating how to fix this, I also found a way to change python on Mac to python3 as standard, so I will summarize it.
First, install pyenv
brew install pyenv
next
cat << '__EOF__' >> ~/.bash_profile
Run this on the terminal and paste the code below
## Set path for pyenv
export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
export PATH=${PYENV_ROOT}/bin:$PATH
eval "$(pyenv init -)"
fi
__EOF__
Check if it is pasted correctly with the command below
cat ~/.bash_profile
And do this
source ~/.bash_profile
Next, let's see the version of python that can be installed with pyenv
pyenv install --list
You can check by doing this I chose python 3.7.5 this time, so
pyenv install 3.7.5
You have now installed python 3.7.5 on pyenv
Then switch the standard python version on your Mac
pyenv global 3.7.1
Now that it has switched, let's check it.
python --version
By the way, this switched to python3 as standard, but when I checked what was installed with pip, everything except the original one disappeared.
Maybe the effect of switching? Please note that it seems to be
https://qiita.com/masatomix/items/b1a0ec216ea943c86a2a
Recommended Posts