Skip to content

Python environment setup

Qiang Zhu edited this page Aug 22, 2018 · 11 revisions

1. Conda

It is usually good to use the integrated version of python like conda for the beginners. Download and install the version of conda for your operating system from http://conda.pydata.org/miniconda.html.

$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
# If Mac
$ bash Miniconda3-latest-MacOSX-x86_64.sh

# If Linux
$ bash Miniconda3-latest-Linux-x86_64.sh

pymatgen

$ conda install -c matsci pymatgen

ase

$ conda install -c jochym python-ase

or

$ pip install --upgrade --user ase

glibc

This is a very annoying issue if you work with old centOS distribution. Unfortunately, a lot of supercomputing clusters are still using this old centOS version. One cannot update glibc on Centos 6 safely. However you can install 2.14 alongside 2.12 easily, then use it to compile projects etc. Here is how:

mkdir ~/glibc_install; cd ~/glibc_install 

wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz

tar zxvf glibc-2.14.tar.gz

cd glibc-2.14

mkdir build

cd build

../configure --prefix=/opt/glibc-2.14

make -j4

sudo make install

export LD_LIBRARY_PATH=/opt/glibc-2.14/lib

slow installation from China

Conda installation might be very slow in China. In this case, one could use the mirror provided from the following website

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

More instructions could be found here

2, Direct compilation from the python source code.

Conda is great, but not optimal. It is not efficient for large scale numerical calculation, and sometimes you will find you local library like glibc is not compatible with conda. Therefore, it is better compile python from the source code, instead of Conda.

$ wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tgz
$ tar -xf Python-3.5.6.tgz
$ cd Python-3.5.6
$ ./configure --prefix= /folder address/
$ make
$ make test
$ make install

to install pymatgen and ase

$ pip install pymatgen
$ pip install ase