I'm new to python, but I had to learn python to work with machine learning.
However, probably because I don't know what python is, it is installed globally by default, so I tried to set it properly and I got stuck. So I'll make a note of it.
(It may be common to use anaconda now, but I dared to try it myself.)
it was helpful! : pray: Building an environment with pyenv and virtualenv
Install python3 and scientific calculation library on Ubuntu
#Check the initial state
python -V
-> 2.7.6
sudo apt-get install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev
# http://qiita.com/sobeit@github/items/eb24bbcc02822223d8eb
#Required to use the drawing library
sudo apt-get install python3-tk tk-dev python-tk libfreetype6-dev
#pyenv installation
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
##Setting environment variables (after confirming that it works,~/.bash_Write it in your profile. )
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"
pyenv --version
-> pyenv 20160509
#Display a list of usable items
pyenv install --list
#Try to install
pyenv install 3.5.1
#Set to the default.
pyenv global 3.5.1
python -V
-> 3.5.1
Up to this point, we have been able to use multiple versions properly. However, since it is not possible to use multiple versions of the same version, virtual-pyenv is included.
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
##Setting environment variables (after confirming that it works,~/.bash_Write it in your profile. )
eval "$(pyenv virtualenv-init -)"
# 3.5.Dedicate 1 to the target directory.
pyenv virtualenv 3.5.1 dev1_3.5.1
pyenv local dev1_3.5.1
python -V
-> 3.5.1
Now you can use python properly. Next, put in the library
pip install pandas
pip install matplotlib
Operation check
sample.py
import tkinter as tk
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5, 0.1)
y = np.sin(x)
plt.plot(x, y)
plt.show()
Success if the graph is displayed.
Recommended Posts