From 2ee1091cd624058ef96bdf71829125c2d31ab216 Mon Sep 17 00:00:00 2001 From: HuangJiameng <105633685+HuangJiameng@users.noreply.github.com> Date: Thu, 5 Jan 2023 17:14:37 +0800 Subject: [PATCH 1/3] replace all python3 by sys.executable --- dpgen/data/gen.py | 1 + dpgen/data/surf.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dpgen/data/gen.py b/dpgen/data/gen.py index c64eb4703..2a40c9413 100644 --- a/dpgen/data/gen.py +++ b/dpgen/data/gen.py @@ -708,6 +708,7 @@ def pert_scaled(jdata) : fp_style = "abacus" poscar_name = "STRU" pert_cmd = 'python3 ' + pert_cmd + ' -etmax %f -ofmt %s %s %d %f > /dev/null' %(pert_box, fp_style, poscar_name, pert_numb, pert_atom) + pert_cmd = pert_cmd.replace('python3', sys.executable) for ii in sys_pe : for jj in scale : path_work = path_sp diff --git a/dpgen/data/surf.py b/dpgen/data/surf.py index 0944ac34f..bcf0a61c4 100644 --- a/dpgen/data/surf.py +++ b/dpgen/data/surf.py @@ -495,8 +495,9 @@ def pert_scaled(jdata) : sys_pe.sort() os.chdir(cwd) - pert_cmd = "python "+os.path.join(ROOT_PATH, 'data/tools/create_random_disturb.py') + pert_cmd = "python3 "+os.path.join(ROOT_PATH, 'data/tools/create_random_disturb.py') pert_cmd += ' -etmax %f -ofmt vasp POSCAR %d %f > /dev/null' %(pert_box, pert_numb, pert_atom) + pert_cmd = pert_cmd.replace('python3', sys.executable) for ii in sys_pe : for jj in scale : path_scale = path_sp From 64095ab66e3575d39a52150d226a6a1914b92de4 Mon Sep 17 00:00:00 2001 From: HuangJiameng <105633685+HuangJiameng@users.noreply.github.com> Date: Thu, 5 Jan 2023 17:29:39 +0800 Subject: [PATCH 2/3] import sys --- dpgen/data/surf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpgen/data/surf.py b/dpgen/data/surf.py index bcf0a61c4..871e22517 100644 --- a/dpgen/data/surf.py +++ b/dpgen/data/surf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import warnings -import os,json,shutil,re,glob,argparse +import os,json,shutil,re,glob,argparse,sys import numpy as np import subprocess as sp import dpgen.data.tools.hcp as hcp From fd9e2a3300afa8abf0a0f2d44d0e06f85722ef1e Mon Sep 17 00:00:00 2001 From: HuangJiameng <105633685+HuangJiameng@users.noreply.github.com> Date: Thu, 5 Jan 2023 21:55:28 +0800 Subject: [PATCH 3/3] replace python3 in command with sys.executable in a more direct way --- dpgen/data/gen.py | 3 +-- dpgen/data/surf.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dpgen/data/gen.py b/dpgen/data/gen.py index 2a40c9413..6cc3ff997 100644 --- a/dpgen/data/gen.py +++ b/dpgen/data/gen.py @@ -707,8 +707,7 @@ def pert_scaled(jdata) : if jdata['init_fp_style'] == "ABACUS": fp_style = "abacus" poscar_name = "STRU" - pert_cmd = 'python3 ' + pert_cmd + ' -etmax %f -ofmt %s %s %d %f > /dev/null' %(pert_box, fp_style, poscar_name, pert_numb, pert_atom) - pert_cmd = pert_cmd.replace('python3', sys.executable) + pert_cmd = sys.executable + ' ' + pert_cmd + ' -etmax %f -ofmt %s %s %d %f > /dev/null' %(pert_box, fp_style, poscar_name, pert_numb, pert_atom) for ii in sys_pe : for jj in scale : path_work = path_sp diff --git a/dpgen/data/surf.py b/dpgen/data/surf.py index 871e22517..ed33e9de7 100644 --- a/dpgen/data/surf.py +++ b/dpgen/data/surf.py @@ -495,9 +495,8 @@ def pert_scaled(jdata) : sys_pe.sort() os.chdir(cwd) - pert_cmd = "python3 "+os.path.join(ROOT_PATH, 'data/tools/create_random_disturb.py') + pert_cmd = sys.executable + ' ' + os.path.join(ROOT_PATH, 'data/tools/create_random_disturb.py') pert_cmd += ' -etmax %f -ofmt vasp POSCAR %d %f > /dev/null' %(pert_box, pert_numb, pert_atom) - pert_cmd = pert_cmd.replace('python3', sys.executable) for ii in sys_pe : for jj in scale : path_scale = path_sp