When I try to use Jupiter notebook on Mac, I can only select python2

environment

MacOS Catalina 10.15.1

Status

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

How to fix

First, install ipykernel

python3 -m pip install ipykernel

Then run the following command

python3 -m IPython kernelspec install-self

This alone solved it

Digression

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

Referenced articles

https://qiita.com/masatomix/items/b1a0ec216ea943c86a2a

Recommended Posts

When I try to use Jupiter notebook on Mac, I can only select python2
I want to use Linux on mac
I want to AWS Lambda with Python on Mac!
[Python] I want to use only index when looping a list with a for statement
Update python on Mac to 3.7-> 3.8
I get an error when I try to raise Python to 3 series using pyenv on Catalina
Easy to use Jupyter notebook (Python3.5)
Try running Jupyter Notebook on Mac
Steps to install python3 on mac
Update Python on Mac from 2 to 3
I tried Python! ] Can I post to Kaggle on my iPad Pro?
I want to know if you install Python on Mac ・ Iroha
When I try to use pip, SSL module is not available.
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
Things to watch out for when creating a Python environment on a Mac
How to use gcc when compiling extension modules from setup.py on Mac
I want to display an image on Jupyter Notebook using OpenCV (mac)
How to erase Python 2.x on Mac.
Memorandum on how to use gremlin python
A memorandum because I stumbled on trying to use MeCab in Python
Try to poke DB on IBM i with python + JDBC using JayDeBeApi
When I tried to use Python on WSL (windows subsystem for linux), it got stuck in Jupyter (solved)
I managed to solve the situation where Python does not work on Mac
I want to use Python in the environment of pyenv + pipenv on Windows 10
I stumbled on the character code when converting CSV to JSON in Python
I tried to use Resultoon on Mac + AVT-C875, but I was frustrated on the way.
I want to use MATLAB feval with python
Easy way to use Python 2.7 on Cent OS 6
When I try matplotlib in Python, it says'cairo.Context'
How to use Python Kivy ④ ~ Execution on Android ~
I want to use Temporary Directory with Python2
Try working with Mongo in Python on Mac
I want to use ceres solver from python
What I did when updating from Python 2.6 to 2.7
[Question] What happens when I use% in python?
Try importing MLB data on Mac and Python
Use Tor to connect from urllib2 [Python] [Mac]
python on mac
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
When I try to import pandas on macOS I get the error No module named'_bz2'
Steps to use the AWS command line interface (Python / awscli) on Mac OS X
I want to use Mac / emacs key bindings (keyboard shortcuts) on Ubuntu xkeysnail recommendations
When I try to update the data on DynamoDB with Python (boto3), I get "ExpressionAttributeNames contains invalid key: Syntax error; key: <key name>"
When I tried to introduce python3 to atom, I got stuck
Preparing to use aws cli on Mac OS X
I tried to summarize how to use matplotlib of python
I tried Python on Mac for the first time.
I tried to implement Minesweeper on terminal with python
Install selenium on Mac and try it with python
Steps to install the latest Python on your Mac
Preferences to generate animated GIFs from Python on Mac
I wanted to use the Python library from MATLAB
How to exit when using Python in Terminal (Mac)
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
How to use Django on Google App Engine / Python
Only size-1 arrays can be converted to Python scalars
Minimum memo when using Python on Mac (pyenv edition)
I want to use the R dataset in python
What I was addicted to when using Python tornado
I want to do something in Python when I finish
Minimum notes when using Python on Mac (Homebrew edition)