linux操作系统安装phonopy
转自https://zhuanlan.zhihu.com/p/26894911
linux下超详细教程安装phonopy
phonopy安装:
第一步:准备文件##
-
python-3.6 (https://www.python.org/downloads/source/)
-
numpy-1.11.2 (Obtaining NumPy & SciPy libraries)
-
lxml-3.6.4 (Processing XML and HTML with Python)
-
matplotlib-1.5.0 (Browse Files at SourceForge.net)
-
PyYAML-3.12 (PyYAML)
-
phonopy-1.11.0 (phonopy)
Note:前5个包也可以用yum 或 apt-get 安装##
第二步:安装Python-3.6.0b3.tar.xz##
$tar xvf Python-3.6.0b3.tar.xz
$cd Python-3.6
$./configure --prefix= /home/…/phonopy/Python-3.6/build
#在python解压目录事先新建build目录,省略部分根据每个人电脑而定
$make
$make install
设置环境变量###
$vi ~/.bashrc
在.bashrc文件末尾加入:
$export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/…/phonopy/Python-3.6/build/lib
$export PATH=$PATH:/home/…/phonopy/Python-3.6/build/bin
$export PATH=/home/…/phonopy/Python-3.6:$PATH
$source ~/.bashrc
测试###
命令行输入python3.6,若成功会出现(避免和系统自带/usr/bin混淆)
Python 3.6.0b3 (default, Nov 6 2016, 02:12:05)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
第三步:安装numpy-1.11.2.tar.gz##
$tar xzvf numpy-1.11.2.tar.gz
$cd numpy-1.11.2
$cp site.cfg.example site.cfg
$vi site.cfg:
修改文件中如下所示部分:
# [mkl]
# library_dirs = /opt/intel/mkl/10.0.1.014/lib/32/
# lapack_libs = mkl_lapack
# mkl_libs = mkl, guide
注意:mkl前面的注释一定要去掉,此外,左端不能留空格。
修改后的如下(根据实际情况修改):
[mkl]
library_dirs = /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64
include_dirs = /opt/intel/composer_xe_2013_sp1.2.144/mkl/include
lapack_libs = mkl_lapack95_lp64
mkl_libs = mkl_def,mkl_intel_lp64,mkl_intel_thread,mkl_core,guide,iomp5
(最后一行逗号为英文输入法下面的)
$python3.6 setup.py build --help-fcompiler #查看下可用的编译器,结果发现--fcompiler=intelem可用
$python3.6 setup.py build --fcompiler=intelem
$python3.6 setup.py install --home=Python3.6解压目录/pymodule
(pymodule是自己在python解压目录下新建的numpy安装目录)
$vi ~/.bashrc
添加下面内容:
PYTHONPATH="${PYTHONPATH}:/home/…/phonopy/Python3.6/pymodule/lib/python"
export PYTHONPATH
export PATH=/home/…/phonopy/Python-3.6/pymodule/bin:$PATH
export PYTHONPATH=/home/…/phonopy/Python-3.6/pymodule/lib/python
$source ~/.bashrc
让python知道到哪里去找模块
测试python是否能够调用numpy:###
$cd ..
(退出 numpy的目录)
这一步一定要做,不然会出错, ImportError: Error importing numpy.
$python3.6
进入python界面
>>>import numpy
执行 numpy 看是否出错
>>>print numpy.version.version
查看numpy的版本
第四步:安装lxml-3.6.4.tgz##
$tar xzvf lxml-3.6.4.tgz
$cd lxml-3.6.4
$vi ~/.bashrc #添加下面内容:
PYTHONPATH="${PYTHONPATH}:/home/…/phonopy/Python3.6/lxml/lib/python"
(lxml是自己在python解压目录下新建的lxml安装目录)
$source ~/.bashrc
$python3.6 setup.py install --home=Python3.6解压目录/lxml
第五步:安装matplotlib-1.5.0.tar.gz##
$tar xzvf matplotlib-1.5.0.tar.gz
$cd matplotlib-1.5.0
$vi ~/.bashrc
添加下面内容:
PYTHONPATH="${PYTHONPATH}:/home/…/phonopy/Python3.6/matplotlib /lib/python"
(matplotlib是自己在python解压目录下新建的matplotlib安装目录)
$source ~/.bashrc
$python3.6 setup.py install --home=Python3.6解压目录/ matplotlib
第六步:安装PyYAML-3.12.tar.gz##
$tar xzvf PyYAML-3.12.tar.gz
$cd PyYAML-3.12
$vi ~/.bashrc
添加下面内容:
PYTHONPATH="${PYTHONPATH}:/home/…/phonopy/Python3.6/pyyaml/lib/python"
(pyyaml是自己在python解压目录下新建的pyyaml安装目录)
$source ~/.bashrc
$python3.6 setup.py test
$python3.6 setup.py install --home=Python3.6解压目录/pyyaml
第七步:安装phonopy-1.11.0.tar.gz##
$tar xzvf phonopy-1.11.0.tar.gz
$cd phonopy-1.11.0
$python3.6 setup.py install
把/home/…/phonopy/phonopy-1.11.0/build/scripts-3.6的phonopy拷贝到usr/bin
测试###
在phonopy目录下命令行输入phonopy:
结果显示:
结果显示:
参考资料:##
-
linux ubuntu 下 phonopy 的安装步骤
-
Linux下安装Phonopy_雁过留痕Neo_新浪博客
-
linux系统vasp5.2+phonopy安装 - 第一原理 - 小木虫 - 学术 科研 互动社区
-
小木虫论坛
-
linux下超详细安装phonopy教程-第一性原理-计算化学公社
appendix:PHONOPY的安装##
参考资料https://atztogo.github.io/phonopy/
phonopy下载目录https://pypi.python.org/pypi/phonopy
把/home/…/phonopy/phonopy-1.11.0/build/scripts-3.6的phonopy拷贝到usr/bin
安装依赖###
- Python and its header files
- numpy
- matplotlib
- python-yaml (pyyaml)
- python-h5py (h5py)
前四个可通过yum包管理器安装
#yum provides python-dev python-numpy python-matplotlib python-yaml
#yum install python-dev python-numpy python-matplotlib python-yaml
CentOS 7 下通过epel扩展源才能安装h5py
#yum -y install epel-release
#yum provides h5py
#yum install ....
另外pip也可以通过epel安装
#yum provides pip
CentOS7 yum安装matplotlib时需要安装大量的依赖包,对于老系统,大量更新会出现问题。换成pip安装
$sudo pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple
清华大学开源镜像站pip目录(校园网):https://pypi.tuna.tsinghua.edu.cn/simple
安装Phonopy##
- Download the source code at
https://pypi.python.org/pypi/phonopy
and extract it:
$ tar xvfz phonopy-1.11.12.31.tar.gz
$ cd phonopy-1.11.12.31
The other option is using git to clone the phonopy repository from github:
$ git clone https://github.com/atztogo/phonopy.git
$ cd phonopy
- Assuming the installation location is those shown in the step 3, set $PATH and $PYTHONPATH:
export PYTHONPATH=~/.local/lib:$PYTHONPATH
export PYTH=~/.local/bin:$PATH
in your .bashrc (or maybe .bash_profile), .zshenv, or other script for the other shells.
在安装前先设置路径变量PYTHONPATH与PATH
3. 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
Watching carefully where the phonopy commands and library are installed. Those locations can be ~/.local/bin and ~/.local/lib directories, respectively.
如果要自定义安装目录
$ python setup.py install --home=...
测试###
在phonopy目录下命令行输入phonopy:
结果显示: