Installing python3 on Ubuntu
The history you put in. The included libraries are numpy, scipy, matplotlib, seaborn, jupyter, etc. Mainly installed with pip on virtualenv. There seems to be another way to put it in with apt or anaconda. (That seems to be more stable.)
Postscript: 2016/09/26 Anaconda is easier to manage, and it seems that the packages that are created are de facto, such as those that support anaconda. Therefore, the method described below is not recommended.
#Put something in.
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential
sudo apt-get -y install python3-dev
python -V
python3 -V
#Type python to get python3.(Postscript: It seems that you should not do it because it causes a bug)
#echo alias python=python3 >> ~/.bash_aliases
#source ~/.bash_aliases
#python -V
#Insert pip.
sudo apt-get install python3-setuptools
sudo easy_install3 pip
#Make sure the location of pip is python3.
pip -V
#What is currently in
pip list
#Put virtualenv
sudo pip install virtualenv
#Create a project directory
mkdir ./projectPath
cd ./projectPath
#Create an environment and start
virtualenv venv
source venv/bin/activate
#Add to gitignore
#echo venv >> .gitignore
#Verification
pip list
#I will try to put various things below using pip.
#Put numpy.
pip install numpy
#Insert scipy. There is a fortran compiler.
sudo apt-get install libatlas-base-dev gfortran
pip install scipy
#matplotlib,Insert seaborn. There is freetype.
sudo apt-get install libpng-dev
sudo apt-get install libfreetype6-dev
pip install matplotlib
pip install seaborn
#The following may not be necessary. When using qt4 and pyside with matplotlib.
sudo apt-get install qt-sdk
sudo apt-get install cmake
sudo pip install pyside
#Write to matplotlib config file
vim ~/.config/matplotlib/matplotlibrc
#backend : qt4agg
#backend.qt4 : PySide
#Jupyter
pip install jupyter
#test library
pip install nose
#Other
pip install quandl
pip install scikit-learn
#Write it down
pip freeze > requirements.txt
#Exit the virtual environment.
deactivate
Let's write a sample code.
test.py
import numpy as np
import pandas as pd
import seaborn as sns
x = np.random.normal(size=100)
sns.distplot(x, kde=False, rug=False, bins=10)
seaborn spits an error when importing, but it works while spitting on ipython.
ipython It seems to be an enhanced version of the dialogue environment. The following is a bulleted list of what I noticed. You can read the explanation by adding? For magic commands. (Example: #run?)
I had to specify something like qt in my environment. It seems that you can usually go with matplotlib inline.
%matplotlib qt4
ipython --matplotlib qt4
%load filename.py
%run filename.py
%%writefile filename.py
...
Overwrite file with what you wrote after the command
%history -n
%history -n range 2-3
%save -a filename.py 2
Above, the history number is specified and saved. You can also specify In [n], Out [n], etc. Addition instead of overwriting with the -a option.
%store foo >> a.txt
It feels like a word for scientific calculations in a browser editor. ipython is the core. It is a notebook cut out from iPython, and can handle not only python but also ruby and haskell notebooks (.ipynb). It can also be a server.
jupyter notebook
Start with
You can create a new notebook by selecting python3 from new in the upper right.
Edit line by line. You can create a new line with the plus on the upper left. The line type is code, markdown, etc. You can choose from the upper right.
If you write the code, press ctrl + enter to execute it and the result will be displayed on the screen.
If you want to display the graph
%matplotlib inline
To execute.
Recommended Posts