The instructions are based on using the Anaconda software distribution, which provides platform-independent package management for Python and other software in self-contained user-specific environments.
This is highly recommended.
Download the Anaconda software from https://www.anaconda.com/download/#macos
Document for the software can be found here
If you choose to go with something light, you may consider getting miniconda.
Choose Anaconda if you:
Choose Miniconda if you:
$ which python
$ python --version
which dump out the following output in my case:
/Users/hajsong/anaconda3/bin/python
Python 3.7.0
If you want to install different version of python (e.g. python 3.6), you can create a new environment where python 3.6 becomes default version.
conda create -n py36 python=3.6 anaconda
To activate this environment, use:
source activate py36
To deactivate an active environment, use:
source deactivate
In window,
activate myenv
deactivate
If you want to remove the environment ‘py36’, try
conda remove --name py36 --all
It is easy to manage (install and update) packages with Anaconda (or Miniconda). For instance, if you want to install numpy package,
conda install numpy
If you want to update numpy package,
conda update numpy
Ipython provides an interactive environment for doing python.
It is included in the Anaconda software and you can visit its document page.
If you want to launch Jupyter notebook in one of your environments (e.g. py36), activate that environment first before starting Jupyter notebook.
To launch ipython, just do
ipython
To launch Jupyter notebook, type
jupyter notebook
You might experience the delay of bringing the figure that you made remotely up on your local machine. This pain can be alleviated if you run Jupyter notebook on the remote server. Instead of opening up the web browser on the remote server, you can request the export the content to the port.
To do this, launch Jupyter notebook on the remote server as the following.
jupyter notebook --no-browser --port=8889
You can change the number for the port.
Then, on your local machine, connect to your server and receive the data by typing the following command.
ssh -N -f -L localhost:8899:localhost:8889 [yourid]@[server_address]
Make sure that the second localhost number match the one on the remote server. Then, open up the web browser and go to “localhost:8899” by typing it in the address section. The web browser might ask the password, and it appears on the terminal where you launch Jupyter notebook.