Anaconda installation on CentOS



Anaconda package is very useful tool for data analysis by python language. This article shows how to install it on CentOS.



What is Anaconda

Nowadays the usage of python language is being more popular than before for the purpose of machine learning or processing data. Anaconda package is consists of not only python engine but also IDE, web-base editor or some useful tools. When you just install anaconda, you can use these bundled useful tools.

CentOS7 has python 2 as a default but in this example we use Anaconda with python3.

Step1 : pyenvのインストール

At first let’s install pyenv which is manage some of python version easily. If you install pyenv, you can switch python2 or python3 at any time.

Here is the command to install pyenv.

#Install pyenv by git command	
$ git clone git:// ~/.pyenv	

#Add the path in .bash_profile	
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile	

#Definition of path of $PYENV_ROOT
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile	

#Initializing pyenv
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile	

#Reload bashrc
$ source ~/.bashrc

Step2 : Installation of Anaconda3

You can check which version of anaconda is available now with following commands.

#Check available anaconda ver.
$ pyenv install --list | grep anaconda

After deciding which version you want to use, you can get anaconda with ‘pyenv install’ .

#Installation of anaconda
$ pyenv install anaconda3-5.3.1
    Installed to /.pyenv/versions/anaconda3-5.3.1

#Reconstruction of hash table
$ pyenv rehash

#definition of anaconda environment
$ pyenv global anaconda3-5.3.1

#adding path
echo 'export PATH="$PYENV_ROOT/versions/anaconda3-5.3.1/bin/:$PATH"' >> ~/.bashrc

$ source ~/.bashrc

#updating of conda
conda update conda

#confirmation of python
$ pyenv -V
 Python 3.7.0 (default, Jun 28 2018, 13:15:42)

You can find python3 environment was constructed in your CentOS. Please try it.




Your email address will not be published. Required fields are marked *


Connection to PostgreSQL, Oracle&MySQL from Python

Contents1 Overview2 How to connect PostgreSQL3 Connect to MySQL4 Oracleの場合 Overview There are some samples to connect PostgreSQL, Oracle, MySQL from Python. How to connect PostgreSQL Package installation pip install psycopg2 Example import psycopg2 HOST = ‘your_host’ PORT = ‘5432’ DB_NAME = ‘your_db_name’ USER = ‘your_user_name’ PASSWORD = ‘your_password’ conn = psycopg2.connect("host=" + HOST + " port=" + PORT + " dbname=" + DB_NAME + " user=" + USER + " password=" + PASSWORD ) cur = conn.cursor() cur.execute("select version()") rows = cur.fetchall() cur.close() conn.close() print(rows) Connect to MySQL Package installation pip install mysqlclient Example import MySQLdb HOST = ‘your_host’ …

【Python】Changing images periodically with tkinter

Contents1 Overview2 Python library to be used3 Step1 : Display a image with tkintertkinter4 Step2 : Changing images5 Summary Overview There is a good library in python to make GUI, that is tkinter. It can display images too. Here, we are trying to change images periodically with tkinter. Python library to be used Following three libraries are used. tkinter ‘tkinter’ is used to make GUI. PIL(pillow) ‘PIL’ is used to deal with images in the python. threading ‘threading’ is used to change images automatically. Detail about that will be explained later. By the way, if you are using anaconda which …

Python : Insert dataframe data into MySQL table 

Contents1 Overview2 Environments3 Step1 : Making the table4 Step2 : Making data5 Step3 : Inserting data into MySQL table6 Additional explanation Overview Dataframe type in python is so useful to data processing and it’s possible to insert data as dataframe into MySQL . There is a sample of that. Environments Python 3.7.3MySQL 5.5.62 Step1 : Making the table Defining a table like the following. > CREATE DATABASE testdb; > CREATE TABLE testdb.mysql_table( col1 int ,col2 int ,col3 int ); Step2 : Making data Making data for insert from python. the data should be the same type as the table you …

【Python】Transforming datetime to date and time with pandas dateframe

Contents1 Original Data2 Transforming dataframe to date and time. Original Data This code is to make sample dataframe. import pandas as pd import datetime as dt df = pd.DataFrame([dt.datetime(2020,6,1,0,0,0),dt.datetime(2020,6,2,10,0,0),dt.datetime(2020,6,3,15,0,0)],columns=[’datetimes’])     datetimes 0 2020-06-01 00:00:00 1 2020-06-02 10:00:00 2 2020-06-03 15:00:00 Transforming dataframe to date and time. It can realize to use lambda & apply functions like following. df[’dates’] = df[’datetimes’].apply(lambda x :,x.month, df[’times’] = df[’datetimes’].apply(lambda x : dt.time(x.hour,x.minute,x.second))      datetimes      dates   times 0 2020-06-01 00:00:00 2020-06-01 00:00:00 1 2020-06-02 10:00:00 2020-06-02 10:00:00 2 2020-06-03 15:00:00 2020-06-03 15:00:00 If you want to get with string, these code is better. df[’dates’] …

【Python】From DataFrame To list type

Contents1 Overview2 Example table in databse3 Solution Overview Pandas can get data from a database with read_sql easily.Here we can show how to convert dataframe to list type for only one row from database. Example table in databse a,b,c are columns of this test_table. abc110100220200330300440400test_table Let’s get only “a” column from this table with pandas.These are sample code. import pandas as pd import psycopg2 connection = psycopg2.connect(host=’host’, dbname=’database’, user=’username’, password=’password’) df = pd.read_sql("SELECT a FROM test_table", connection) df.head() Result If you want to convert this result from dataframe to list type, you may think like [1, 2, 3, 4]. There …

Language Switcher