過去記事 PyMOL200715 PyMOL/150
本家様 http://pymol.org/
open sourceでソースコードが提供されてます https://github.com/schrodinger/pymol-open-source
コンパイルせずに使えるバージョンは、本家様から入手可能で、open source版よりも機能が強化されてますが、有償です。
python2系は2020年1月1日にサポート切れてpython3系が主流なのですが、アプリによってはまだpython2系も多い.
PyMOLはpython3に対応済みです.
CentOS7にpython3をインストールすればコンパイル可能です.
コンパイル †
PyMOLのソースコードをgithubから取得します.
[root@centos7 ~]# mkdir -p /apps/src && cd /apps/src
[root@centos7 src]# git clone https://github.com/schrodinger/pymol-open-source
[root@centos7 src]# cd pymol-open-source/
ここで以前のようにコンパイルを試みると
[root@centos7 pymol-open-source]# python -V
Python 2.7.5
[root@centos7 pymol-open-source]# python setup.py build
File "setup.py", line 227
out.write(f'set PYMOL_PATH={pymol_path}' + os.linesep)
^
SyntaxError: invalid syntax
[root@centos7 pymol-open-source]#
と文法が違うとエラーに合う.
っでどのようにするかであるが、
- python3をCentOS7に入れる
- PyMOLにあるpy2 branchにしてpython2でコンパイルする
があるみたい. 前者で対応するのがいい筋かもしれない. 既にpython2はサポートが切れているのだから.
python3でPyMOLをコンパイルする †
既に開発環境はインストール済みとします[yum groupinstall "Development Tools"]
まずは追加パッケージとして[python3-devel]らをインストールします
[root@centos7 ~]# yum install epel-release
[root@centos7 ~]# yum install --enablerepo=epel python3-devel glew-devel glm-devel netcdf-devel libpng-devel libxml2-devel freetype-devel
(RHEL8系なら)
dnf install --enablerepo=powertools,epel python3-devel platform-python-devel glew-devel glm-devel netcdf-devel
その後に本体を調理します
[root@centos7 ~]# cd /apps/src/pymol-open-source
[root@centos7 pymol-open-source]# python3 setup.py build
:
:
[root@centos7 pymol-open-source]# python3 setup.py install --prefix=/apps/pymol
これで完了.
呼び出すpymolファイルの中身はこんな感じ
[root@centos7 ~]# cat /apps/pymol/bin/pymol
#!/bin/sh
exec "/usr/bin/python3" "/apps/pymol/lib64/python3.6/site-packages/pymol/__init__.py" "$@"
[root@centos7 ~]#
python3で実行される
実行 †
ってユーザで実行してみると
[illya@centos7 ~]$ /apps/pymol/bin/pymol
Qt not available, using GLUT/Tk interface
Traceback (most recent call last):
File "/apps/pymol/lib64/python3.6/site-packages/pymol/__init__.py", line 73, in <module>
pymol.launch(args)
File "/apps/pymol/lib64/python3.6/site-packages/pymol/__init__.py", line 432, in launch
_cmd.runpymol(None, block_input_hook)
NotImplementedError: compile with --glut
[illya@centos7 ~]$
と残念な結果になる. [--glut]を入れて再コンパイルしてねと言われるが、単に「Qt」ライブラリがないからである。
っでそのQtライブラリを入れる
[root@centos7 ~]# yum install --enablerepo=epel python36-qt5
(RHEL8系なら)
dnf install python3-qt5
そうすればPyMOLを実行できます
[illya@centos7 ~]$ /apps/pymol/bin/pymol
PyMOL(TM) Molecular Graphics System, Version 2.5.0a0.
Copyright (c) Schrodinger, LLC.
All Rights Reserved.
Created by Warren L. DeLano, Ph.D.
PyMOL is user-supported open-source software. Although some versions
are freely available, PyMOL is not in the public domain.
If PyMOL is helpful in your work or study, then please volunteer
support for our ongoing efforts to create open and affordable scientific
software by purchasing a PyMOL Maintenance and/or Support subscription.
More information can be found at "http://www.pymol.org".
Enter "help" for a list of commands.
Enter "help <command-name>" for information on a specific command.
Hit ESC anytime to toggle between text and graphics.
Warning: GL_DOUBLEBUFFER=0
Detected OpenGL version 2.1. Shaders available.
Geometry shaders not available
Detected GLSL version 1.20.
OpenGL graphics engine:
GL_VENDOR: VMware, Inc.
GL_RENDERER: llvmpipe (LLVM 7.0, 256 bits)
GL_VERSION: 2.1 Mesa 18.3.4
Detected 4 CPU cores. Enabled multithreaded rendering.

PyMOLにあるpy2 branchにしてpython2でコンパイルする †
従来通りのPython2でコンパイルしたいなら、まずgitでpy2 ブランチに移る
[root@centos7 pymol-open-source]# git branch --all
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/py2
[root@centos7 pymol-open-source]# git checkout py2
Branch py2 set up to track remote branch py2 from origin.
Switched to a new branch 'py2'
[root@centos7 pymol-open-source]# git branch
master
* py2
[root@centos7 pymol-open-source]#
そしてコンパイルに必要な追加パッケージをインストールします
[root@centos7 ~]# yum install epel-release
[root@centos7 ~]# yum install --enablerepo=epel python-devel glew-devel glm-devel netcdf-devel libpng-devel libxml2-devel freetype-devel
その上で、
[root@centos7 pymol-open-source]# python -V
Python 2.7.5
[root@centos7 pymol-open-source]# python setup.py build
[root@centos7 pymol-open-source]# python setup.py install --prefix=/apps/pymol
ちなみに/apps/pymol/bin/pymolの中身はこんな感じ
[root@centos7 pymol-open-source]# cat /apps/pymol/bin/pymol
#!/bin/sh
export PYMOL_PATH="/apps/pymol/lib64/python2.7/site-packages/pymol/pymol_path"
exec "/usr/bin/python" "/apps/pymol/lib64/python2.7/site-packages/pymol/__init__.py" "$@"
[root@centos7 pymol-open-source]#
こちらの実行には「PyQt4」パッケージのインストールが必要です
加えて、py2 branchのソースはmasterよりも古いようです
PyMOL(TM) Molecular Graphics System, Version 2.5.0a0. <-- Python3で作ったPyMOLのバージョン
PyMOL(TM) Molecular Graphics System, Version 2.4+py2. <-- py2ブランチで作ったPyMOLのバージョン
素直にpython3を入れた方がいいのかも.
CentOS8 †
CentOS8でのコンパイルでは
開発環境は既にインストール済みとして
dnf install epel-release
(コンパイルのため)
dnf install --enablerepo=PowerTools,epel glew-devel python3-devel netcdf-devel glm-devel libpng-devel libxml2-devel freetype-devel
python3 setup.py build
python3 setup.py install --prefix=/apps/pymol
(Qtで表示させるため)
dnf install python3-qt5
これでCentOS8内で利用可能となる.
windowsPCにXサーバを入れて画面表示する際はMobaXterm経由なら大丈夫。Xming経由では起動しない(200715現在)
Xming経由でのエラー内容
[illya@centos8 ~]$ /apps/pymol/bin/pymol
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted (core dumped)
[illya@centos8 ~]$
MobaXterm経由なら表示はできているが、下記エラーが表示される。
[illya@centos8 ~]$ /apps/pymol/bin/pymol
PyMOL(TM) Molecular Graphics System, Version 2.5.0a0.
Copyright (c) Schrodinger, LLC.
All Rights Reserved.
Created by Warren L. DeLano, Ph.D.
PyMOL is user-supported open-source software. Although some versions
are freely available, PyMOL is not in the public domain.
If PyMOL is helpful in your work or study, then please volunteer
support for our ongoing efforts to create open and affordable scientific
software by purchasing a PyMOL Maintenance and/or Support subscription.
More information can be found at "http://www.pymol.org".
Enter "help" for a list of commands.
Enter "help <command-name>" for information on a specific command.
Hit ESC anytime to toggle between text and graphics.
qt.qpa.xcb: QXcbConnection: XCB error: 145 (Unknown), sequence: 175, resource id: 0, major code: 139 (Unknown), minor code: 20
Detected OpenGL version 3.1. Shaders available.
Geometry shaders not available
Detected GLSL version 1.40.
OpenGL graphics engine:
GL_VENDOR: VMware, Inc.
GL_RENDERER: llvmpipe (LLVM 9.0.0, 256 bits)
GL_VERSION: 3.1 Mesa 19.3.4
Detected 4 CPU cores. Enabled multithreaded rendering.
[illya@centos8 ~]$
これはここを参照して回避できた
https://stackoverflow.com/questions/51218417/qxcbconnection-xcb-error-145-unknown-error-message-starting-spyder-with-moba