'Run Python module in another code but with an older version
I am using Python 3.10 but I want to run a Python module with Python 3.6 and use the result inside my code(that written with Python 3.10)
Please help me to solve it
thanks
Solution 1:[1]
- Create a
.pyscript that should be run with python3.6 - Make the script prints your expected result
# script.py
import sys
print(sys.version[:6])
- Use subprocess to get it
import subprocess
python3_6_result = subprocess.check_output(["python3.6", "script.py"])
print(python3_6_result) # 3.6.15
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
