I want to run ‘python -m tester test_bench.py’ using subprocess.run
‘’’
#!python3.10
brief.py
import os, sys, pathlib, subprocess
import tester
py_exe = r’c:\programs\apps\py.exe’
two = ‘tester’
name = ‘bench.py’
print(‘Process’, two, name)
cmd = [py_exe]
cmd.append(F’-m {two}')
cmd.append(name)
current = pathlib.Path(os.getcwd())
print(‘CWD’, current)
print(‘command’, ’ '.join(cmd))
subprocess.run(cmd, cwd = current)
#~ #!python3.10
#~ test_bench.py
#~ import os, sys
#~ print(‘***’, os.getcwd())
#~ #!python3.10
#~ tester.py
#~ import os, sys
#~ print(‘tester’, sys.argv)
#~ py -m tester test_bench.py
#~ tester [‘H:\Computers\PythonTools\RunScript\tester.py’, ‘test_bench.py’]
#~ py brief.py
#~ tester [‘brief.py’]
#~ Process tester bench.py
#~ CWD H:\Computers\PythonTools\RunScript
#~ command c:\programs\apps\py.exe -m tester bench.py
#~ C:\Programs\Python310\python.exe: No module named tester
‘’’
but python can not find the the module, even though it is in the same drectory.
Any ideas?
Thanks in advance
John