Saturday, March 4, 2017

Python And Jupyter Installation

Python And Jupyter Installation

Install Python in Mac OS X

1. Using brew is the fastest way.

python2

> brew install python

python3

> brew install python3

2. Check The Version

> python --version
Python 2.7.10
> python3 --version
Python 3.5.1

3. Check The Location of Python and Setup The Path

Mac OS X has built-in Python 2.7. By using ‘which’ command to check the location where Python installed, you can find out whether is it the system built-in python.

> which python
usr/bin/pythonsystem built-in 

In order to access to the correct version of Python installed, we need to add /usr/local/bin to $PATH.

You can use vim to edit the /etc/paths

> sudo vim /etc/paths

make sure that /usr/local/bin is before /usr/bin.

or just…

> export PATH=/usr/local/bin:$PATH

Close the terminal and reopen it again to make sure all the settings are effective.

Then check the location of Python again.

> which python 
/usr/local/bin/python
> which python3
/usr/local/bin/python3

Done!

If you always using Python 3, you can edit the setting:

> vim ~/.bash_profile

and add:

alias python="python3"

Installing Jupyter

Python2

> pip install jupyter

Python3

> pip3 install jupyter

After installation, using following command to start jupyter.

> jupyter notebook

No comments:

Post a Comment