hon installation: a super short documentation
MacOS
The Python installation is done using Xcode and MacPorts.
Get Xcode and Xcode command line tools
In a termminal,
- xcode-select --install
and follow the instructions.
Get MacPorts
Go to http://www.macports.org/install.php and follow the instructions.
To upgrade, from time to time, the MacPorts:
- sudo port selfupdate
- port upgrade outdated
Get Python
The python version that will be installed is the 3.4.
If you want to install a version XX, just replace in the commands 34 by XX.
In a terminal:
- sudo port install python35
- sudo port install py35-setuptools py35-nose
- # scientific librairies
- sudo port install py35-numpy py35-scipy py35-matplotlib
- # notebook
- sudo port install py35-tornado py35-zmq # to use notebook parallel)
- sudo port install py35-ipython +notebook +parallel py35-jupyter
- # machine learning librairies
- sudo port install py35-pandas py35-scikit-learn py35-seaborn
To use the command python
sudo port select --set python python35
And it's done!
Check Python
In a terminal, launch python:
- python
and copy paste the following Python commands.
To rapidly check the scientific modules:
- import numpy as np
- import scipy.sparse as sparse
- import matplotlib.pyplot as plt
- d0 = 9*np.ones(10)
- d1 = np.arange(9)
- m = sparse.diags([d1, d0, d1], [-1, 0, 1])
- print(m.toarray())
- a_min, a_max = -1.5, 1.5
- a = np.linspace(a_min, a_max, 100)
- x, y = np.meshgrid(a, a)
- z = np.exp(-x*x-y*y)
- fig, ax = plt.subplots()
- ax.imshow(z, extent=[a_min, a_max, a_min, a_max])
- plt.show()
To rapidly check the machine learning modules:
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- sns.set_style('whitegrid')
- from pandas.io.data import DataReader
- from datetime import datetime
- stocks = ['AAPL', 'NFLX', 'FB']
- end = datetime.now()
- start = datetime(end.year-1, end.month, end.day)
- closing_df = DataReader(stocks, 'yahoo', start, end)['Adj Close']
- closing_df.plot(legend=True, figsize=(10, 4), lw=3)
- return_df = closing_df.pct_change()
- sns.pairplot(return_df .dropna(), size=3)
- plt.draw()
- plt.show()
Other tools
Git
- sudo port install git
- git config --global user.name "Alex Dumas"
- git config --global user.email alex@dumas.fr
One can then install packages from GitHub:
- git clone https://github.com/jakevdp/JSAnimation
- # I picked up a package to create animations in python notebooks
- cd JSAnimation
- python setup.py build
- sudo python setup.py install
Text Editors / IDEs
Xcode (for mac users)
Note that Xcode is aleady installed.
- touch test.py # create an empty file
- open test.py # open the file with Xcode
Sublime
Download http://www.sublimetext.com/3 and install Sublime.
To call Sublime from the Terminal:
- sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin
Then, to open a file using Sublime:
- touch test.py
- subl test.py
Emacs
- sudo port install emacs
- sudo port install emacs-app
- emacs test.py # open the file in the terminal
To use your alt and meta keys as usual
Go to “Emacs” → “Preferences” → “Environment” → “Ns : GNUstep/Mac OS X specific features”
and change the following:
“Ns Command Modifier” → “meta“
“Ns Alternate Modifier” → “No modifier“
To change the background and mouse color
open your “~/.emacs“
paste the following code snippet:
(setq default-frame-alist
(append default-frame-alist
'((foreground-color . "LawnGreen")
(background-color . "Black")
(cursor-color . "LawnGreen"))))
IPython notebook
- ipython notebook
Ubuntu
Just go to the Mac section and replace
- sudo port
by
- sudo get-apt
Debian
Just go to the Mac section and replace
- sudo port
by
- sudo yum
Windows
Get Python
Download and execute a Python version
https://www.python.org/downloads/.
Just go to the Mac section and replace
- sudo port
by
- pip
You can also download the unofficial Windows binaries from
http://www.lfd.uci.edu/~gohlke/pythonlibs
MacOS
The Python installation is done using Xcode and MacPorts.Get Xcode and Xcode command line tools
In a termminal,- xcode-select --install
Get MacPorts
Go to http://www.macports.org/install.php and follow the instructions. To upgrade, from time to time, the MacPorts:- sudo port selfupdate
- port upgrade outdated
Get Python
The python version that will be installed is the 3.4. If you want to install a version XX, just replace in the commands 34 by XX. In a terminal:- sudo port install python35
- sudo port install py35-setuptools py35-nose
- # scientific librairies
- sudo port install py35-numpy py35-scipy py35-matplotlib
- # notebook
- sudo port install py35-tornado py35-zmq # to use notebook parallel)
- sudo port install py35-ipython +notebook +parallel py35-jupyter
- # machine learning librairies
- sudo port install py35-pandas py35-scikit-learn py35-seaborn
-
sudo port select --set python python35
Check Python
In a terminal, launch python:- python
- import numpy as np
- import scipy.sparse as sparse
- import matplotlib.pyplot as plt
- d0 = 9*np.ones(10)
- d1 = np.arange(9)
- m = sparse.diags([d1, d0, d1], [-1, 0, 1])
- print(m.toarray())
- a_min, a_max = -1.5, 1.5
- a = np.linspace(a_min, a_max, 100)
- x, y = np.meshgrid(a, a)
- z = np.exp(-x*x-y*y)
- fig, ax = plt.subplots()
- ax.imshow(z, extent=[a_min, a_max, a_min, a_max])
- plt.show()
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- sns.set_style('whitegrid')
- from pandas.io.data import DataReader
- from datetime import datetime
- stocks = ['AAPL', 'NFLX', 'FB']
- end = datetime.now()
- start = datetime(end.year-1, end.month, end.day)
- closing_df = DataReader(stocks, 'yahoo', start, end)['Adj Close']
- closing_df.plot(legend=True, figsize=(10, 4), lw=3)
- return_df = closing_df.pct_change()
- sns.pairplot(return_df .dropna(), size=3)
- plt.draw()
- plt.show()
Other tools
Git
- sudo port install git
- git config --global user.name "Alex Dumas"
- git config --global user.email alex@dumas.fr
- git clone https://github.com/jakevdp/JSAnimation
- # I picked up a package to create animations in python notebooks
- cd JSAnimation
- python setup.py build
- sudo python setup.py install
Text Editors / IDEs
Xcode (for mac users)Note that Xcode is aleady installed.
- touch test.py # create an empty file
- open test.py # open the file with Xcode
Download http://www.sublimetext.com/3 and install Sublime.
To call Sublime from the Terminal:
- sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin
- touch test.py
- subl test.py
- sudo port install emacs
- sudo port install emacs-app
- emacs test.py # open the file in the terminal
Go to “Emacs” → “Preferences” → “Environment” → “Ns : GNUstep/Mac OS X specific features”
and change the following:
“Ns Command Modifier” → “meta“
“Ns Alternate Modifier” → “No modifier“
To change the background and mouse color
open your “~/.emacs“
paste the following code snippet:
(setq default-frame-alist
(append default-frame-alist
'((foreground-color . "LawnGreen")
(background-color . "Black")
(cursor-color . "LawnGreen"))))
IPython notebook
- ipython notebook
Ubuntu
Just go to the Mac section and replace- sudo port
- sudo get-apt
Debian
Just go to the Mac section and replace- sudo port
- sudo yum
Windows
Get Python
Download and execute a Python version https://www.python.org/downloads/. Just go to the Mac section and replace- sudo port
- pip