I have an application which I am trying to make platform-independent with Python.
I have Python 3.x installed in all 3 OS-(Mac,Win10,Ubuntu)
I have a python script batch.py that calls other python scripts from within itself like this:
import os
import argparse
import shutil
if __name__ == '__main__':
parser.add_argument("-i", "--infolder", default="./pdfs",
help="Input folder with PDFs. Default: ./pdfs")
args = parser.parse_args()
infolder =args.infolder
# Watermarking process
watermark_outfolder = tmp+'/pdfs_watermarked'
if not os.path.exists(watermark_outfolder):
os.makedirs(watermark_outfolder)
else:
for root, dirs, files in os.walk(watermark_outfolder):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
watermark_command = 'python watermark.py --in '+infolder
os.system(watermark_command)
The problem I am having is in Linux, the scripts don't run when I am using os.system('python ... it works only when I run as os.system('python3 ....
On the other hand when I am running it in Win10, it works with python but not with python3.
I tried to put a check for the python version:
if sys.version_info[0] < 3:
watermark_command = 'python watermark.py --in '+infolder
else:
watermark_command = 'python3 watermark.py --in '+infolder
os.system(watermark_command)
Doing this doesn't help, it doesn't run in Win10
watermark.pyalso platform dependent by any chance?