-1

I have two python scripts, which need two different python versions (3.6 or older and 3.8 or newer). To get the information produced from the older versioned script, I want to call it in the newer script on command line and save the results to a file, so that I can use it in the newer Script.

What's the best way to call my older script on command line from the newer one?

making
  • 1
  • 1
  • 1
    Can't you just run the file directly? – Codeman Mar 16 '22 at 15:45
  • 1
    [`subprocess`](https://docs.python.org/3/library/subprocess.html)? – Olvin Roght Mar 16 '22 at 15:45
  • Do both scripts have their virtual environments? You could start a new shell from one script, activate the other script's environment in that shell, run the script, exit the shell, and read the file. In the long run I'd look into removing the dependency on a particular Python version or making the script a reusable package. – Robert Mar 16 '22 at 16:01
  • 3.6 or *older*? What is in the script that prevents python 3.7 (or 3.8, for that matter) from running it? – chepner Mar 16 '22 at 16:15
  • The file includes cntk code, which only supports 3.6 or older – making Mar 16 '22 at 19:38

1 Answers1

0

You could use the os librar to run it.

import os
os.system("py example.py")
Yanni2
  • 176
  • 9