# Installation¶

MPI is not used in phono3py, so the installation is expected to be easy. The detailed installation processes for different environments are described below. The easiest installation with a good computation performance is achieved by using the phono3py conda package (see An example of installation process).

Installation of phonopy before the installation of phono3py is required. See how to install phonopy at https://atztogo.github.io/phonopy/install.html. Phono3py relies on phonopy, so please use the latest release of phonopy when installing phono3py.

## Installation using conda¶

Using conda is the easiest way for installation of phono3py if you are using usual 64 bit linux system. The conda packages for 64bit linux are also found at atztogo channel:

% conda install -c atztogo phono3py

All dependent packages are installed simultaneously.

## Installation using pip¶

PyPI packages are prepared for phonopy and phono3py releases. When installing with PyPI, setup.py is executed locally to compile the part of the code written in C, so a few libraries such as lapacke must exist in the system. Those necessary libraries are explained in the next section.

## Installation from source code¶

When installing phono3py using setup.py from the source code, a few libraries are required before running setup.py script.

For phono3py, OpenMP library is necessary for the multithreding support. In additon, BLAS, LAPACK, and LAPACKE are also needed. These packages are probably installed using the package manager for each OS or conda.

When using gcc to compile phono3py, libgomp1 is necessary to enable OpenMP multithreading support. This library is probably installed already in your system. If you don’t have it and you use Ubuntu linux, it is installed by:

% sudo apt-get install libgomp1

### Installation of LAPACKE¶

LAPACK library is used in a few parts of the code to diagonalize matrices. LAPACK*E* is the C-wrapper of LAPACK and LAPACK relies on BLAS. Both single-thread or multithread BLAS can be used in phono3py. In the following, multiple different ways of installation of LAPACKE are explained.

#### MKL LAPACKE (with multithread BLAS)¶

Phono3py can be compiled with MKL for using LAPACKE. If setup.py finds the file named mkl.py, the contents of mkl.py is read and those are included in the compilation setting. For example, the following setting prepared as mkl.py seems working on Ubuntu 16.04 system:

intel_root = "/opt/intel/composer_xe_2015.7.235"
mkl_root = "%s/mkl" % intel_root
compiler_root = "%s/compiler" % intel_root

'-lmkl_rt']
'-lsvml',
'-liomp5',
'-limf',
mkl_include_dirs_lapacke = ["%s/include" % mkl_root]

This setting considers to use icc but it may be compiled with gcc. With gcc, the compiler related setting shown above (i.e., around compiler_root) is unnecessary. To achieve this installation, not only the MKL library but also the header file are necessary. The libraries are linked dynamically, so in most of the cases, LD_LIBRARY_PATH environment variable has to be correctly specified to let phono3py find those libraries.

#### OpenBLAS provided by conda (with multithread BLAS)¶

The installtion of LAPACKE is easy by conda. It is:

% conda install -c conda-forge openblas

The recent change of openblas package provided from anaconda makes to install nomkl, i.e., numpy and scipy with Intel MKL cannot be used together with openblas. At this moment, this is avoided to install openblas from conda-forge channel. If the python libraries are not yet installed:

% conda install numpy scipy h5py pyyaml matplotlib
% conda install -c conda-forge openblas

When using hdf5 files from NFS mouted location, the latest h5py may not work. In this case, installation of an older version is recommended:

% conda install hdf5=1.8.18

This openblas package contains BLAS, LAPACK, and LAPACKE. When this libopenblas is linked and the else statement of the C macro definition section in setup.py is executed, the following macro are activated:

if use_setuptools:
else:

#### Netlib LAPACKE provided by Ubuntu package manager (with single-thread BLAS)¶

In the versions of Ubuntu-12.10 or later, LAPACKE (http://www.netlib.org/lapack/lapacke.html) can be installed from the package manager (liblapacke and liblapacke-dev):

% sudo apt-get install liblapack-dev liblapacke-dev

#### Compiling Netlib LAPACKE¶

The compilation procedure is found at the LAPACKE web site. After creating the LAPACKE library, liblapacke.a (or the dynamic link library), setup.py must be properly modified to link it. As an example, the procedure of compiling LAPACKE is shown below.

% tar xvfz lapack-3.6.0.tgz
% cd lapack-3.6.0
% cp make.inc.example make.inc
% make lapackelib

BLAS, LAPACK, and LAPACKE, these all may have to be compiled with -fPIC option to use it with python.

#### OpenBLAS provided by MacPorts (with single-thread BLAS)¶

MacPorts, the OpenBLAS package contains not only BLAS but also LAPACK and LAPACKE in libopenblas.

### Building using setup.py¶

If package installation is not possible or you want to compile with special compiler or special options, phono3py is built using setup.py. In this case, manual modification of setup.py may be needed.

https://pypi.python.org/pypi/phono3py

2. and extract it:

% tar xvfz phono3py-1.11.13.39.tar.gz
% cd phono3py-1.11.13.39

The other option is using git to clone the phonopy repository from github:

% git clone https://github.com/atztogo/phono3py.git
% cd phono3py

1. Set up C-libraries for python C-API and python codes. This can be done as follows:

Run setup.py script:

% python setup.py install --user

2. Set $PATH and$PYTHONPATH

PATH and PYTHONPATH are set in the same way as phonopy, see https://atztogo.github.io/phonopy/install.html#building-using-setup-py.

## Installation on macOS¶

macOS users may be able to install phonopy and phono3py on recent macOS. But it requires a basic knowledge on UNIX and python. So if you are afraid of that, please prepare a computer or a virtual machine with a normal linux OS such as Ubuntu-linux-64bit 14.04 or 16.04.

If you think you are familiar with macOS, unix system, and python, the recommended installation process is written at https://atztogo.github.io/phonopy/install.html#using-phonopy-on-mac-os-x, which is more-or-less the same as phonopy, but with openblas, too. An example of the procedure is summarized in the next section.

## An example of installation process¶

For usual 64-bit Linux system:

% wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh

For macOS, it is assumed that gcc compiler is installed on your system. The compiler such as default clang on macOS can’t handle OpenMP, so it can’t be used. The gcc compiler may be installed using homebrew, e.g.:

% brew install gcc

or using MacPort, e.g.:

% sudo port install gcc7 wget

% wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh

Conda provided compiler (gcc for linux and clang for macOS) can be also used instead of system provided compiler, brew, or macport. The detail can be found at https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html.

2. Install conda packages

It is supposed to have the following environment variable:

export PATH=~/.miniconda3/bin:$PATH Then install and update conda: % bash miniconda.sh -b -p$HOME/.miniconda3
% conda update conda

The necessary python libraries and openBLAS are installed by:

% conda install numpy scipy h5py pyyaml matplotlib
% conda install -c conda-forge openblas

When using hdf5 files from NFS mouted location, the latest h5py may not work. In this case, installation of an older version is recommended:

% conda install hdf5=1.8.18

Install the latest phonopy and phono3py:

% export CC=gcc # only for macOS (macport), CC=gcc-7 for homebrew
% git clone https://github.com/atztogo/phonopy.git
% cd phonopy
% python setup.py install --user
% cd ..
% git clone https://github.com/atztogo/phono3py.git
% cd phono3py
% python setup.py install --user
% cd ..

Environment variables PATH and PYTHONPATH must be set appropriately to use phono3py. See see https://atztogo.github.io/phonopy/install.html#building-using-setup-py and https://atztogo.github.io/phonopy/install.html#set-correct-environment-variables-path-and-pythonpath.