Running Python script APPA using locally installed Python2.7  [SOLVED]

MULTIBINIT, aTDEP, ANADDB, optics, cut3d, mrg* postprocessors

Moderators: MMNSchmitt, gonze

Locked
thanusit
Posts: 70
Joined: Thu Jan 14, 2010 4:20 am

Running Python script APPA using locally installed Python2.7

Post by thanusit » Mon Sep 23, 2013 12:01 pm

Dear all

I'm trying to run the python script APPA, provided in abinit-7.4.1 package, for the analysis of Molecular Dynamics output files.

To this, I've installed Python 2.7.5 at a user defined location (to avoid messing up with the default python2.6 of the fedora 13 platform), and the required 3rd-party modules such as PyQT4, Numpy, f2py, etc..

Next, I complied "math.f90" as follows:

$ cd ~/abinit-7.4.1/scripts/post-processing/appa/fortran
$ /path/to/Python2.7.5../bin/f2py -c -I/Path/to/Python2.7.5../lib/python2.7/site-packages/numpy/core/include -I/Path/to/Python2.7.5../include/python2.7 math.f90 -m math

and get the following messages and error at the end
------------------------------------------------------
Traceback (most recent call last):
File "/home/p_thanusit/apps/Python/2.7.5/bin/f2py", line 3, in <module>
import f2py2e
File "/home/p_thanusit/apps/Python/2.7.5/lib/python2.7/site-packages/f2py2e/__init__.py", line 6, in <module>
import tempfile
File "/home/p_thanusit/apps/Python/2.7.5/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "/home/p_thanusit/apps/Python/2.7.5/lib/python2.7/random.py", line 45, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: cannot import name log

---------------------------------------------------

I don't know what's I've done wrong and still missing. Could anyone please give suggestions?


Regards,
Thanusit
Last edited by thanusit on Wed Oct 09, 2013 3:53 am, edited 2 times in total.

thanusit
Posts: 70
Joined: Thu Jan 14, 2010 4:20 am

Re: Running Python script APPA using locally installed Pytho  [SOLVED]

Post by thanusit » Tue Oct 08, 2013 1:30 pm

Dear all

I'm not sure that the following procedure is a proper way to do, but it works for me.

1. Compile the math.f90 using f2py built on python2.6 (default python on my platform). The compile was completed, and I got a file "math.so" in ../appa/fortran.
2. Edit the header line of "appa_nw.py" script so that python2.7.5 is notified, as follows:
-original header line:
#!/usr/bin/env python
-changed to:
#!/path/to/python2.7.5../bin/python
3. Prepare moldyn output files "*_out_HIST" and "*_out_OUT.nc" in a working directory, then run the script by launching
/working-directory..$ /path/to/appa/appa_nw.py input.APPA
or
/working-directory..$ /path/to/appa/appa_nw.py.

Results of the analysis can be successfully obtained.

In addition, to get the "rdf" routine work, the following lines of the appa_nw.py was modified:
#original code: (this causes the script goes no where)

while True:
try:
prmax = input("Choose maximum radius ("+str(MD_file.getRPrim()[0][0]*0.5)+") : ")
if prmax <= MD_file.getRPrim()[0][0]:
break
except:
pass;

# Replace with

while True:
try:
prmax = input("Choose maximum radius (<= lattice constant, Bohrs): ")
if prmax <= 20: #Should make more general by using prmax <= lattice constant (but I don't know how to do it.)
break
except:
pass;

Finally, I can get the rdf results in dat and/or pdf formats.

Regards,
Thanusit

vishank
Posts: 1
Joined: Wed Mar 22, 2017 5:45 pm

Running Python script APPA with PyQt5

Post by vishank » Wed Mar 22, 2017 5:51 pm

Dear All,

I tried to run python script appa.py for post processing of abinit output. However, my python version has PyQt5 instead of PyQt4, and it is not compatible for the libraries used in the script. Would you please suggest a way out to run this script or if there will be a new version of the script supported with PyQt5?

Thank you for your help and suggestions,
Vishank

User avatar
gmatteo
Posts: 291
Joined: Sun Aug 16, 2009 5:40 pm

Re: Running Python script APPA using locally installed Pytho

Post by gmatteo » Wed Mar 22, 2017 10:30 pm

Hi Vishank,

I don't know if someone is trying to port APPA to pyqt5 but you may try to use conda to
create an environment with python2.7 and pyqt4.

Conda will create its own installation directory so you don't have to downgrade/reinstall
the python packages already installed on your system.
These are the steps needed to install pyqt4 with conda:

    * Download conda from https://www.continuum.io/downloads and follow the installation instructions
    * Create a new environment based on python2.7 with: conda create -n appa_env python=2.7
    * Activate the new env with: source activate appa_env
    * Add conda-forge to your channels with: conda config --add channels conda-forge
    * Use conda find pyqt to list the different versions of pyqt available in your channels
    * Install pyqt4 and the associated requirements with conda install pyqt=4.11.4

Locked