0

My sample file in one project is:

import os
feature_name = 'neelam'
combo_boxes = {"'Primary CAN InterfaceComboBox": ["[CanSim, CanSim]", "best_match"],
               "'Secondary CAN InterfaceComboBox": ["[CanSim, CanSim]", "best_match"],
               "Seed Data SimulationComboBox": ["[Off, OFF]", "best_match"],
               "Planter TypeComboBox": ["[_2160_FFT_24R30, 2160 Front Fold 24 Row 30 Inch]", "best_match"],
               "BrandComboBox": ["[CaseIH, Case IH]", "best_match"],
               "LATAM Gran Fertilizer InstalledComboBox": ["[Hydraulic, Hydraulic]", "best_match"],
               "DiagnosticsComboBox": ["[On, ON]", "best_match"]}

for i in combo_boxes:
    log_msg = 'Click on combo box {0} at {1}'.format(i, combo_boxes[i][0].split(",")[1][:-1])
    print(log_msg)

Now I am trying to run sample file from another python script as given:

import os
script_string = r'C:\Neelam\Neelam_Dev\test_automation\FeatureTestScripts\Common\sample.py'
os.system(script_string)

But after running the second file, it is not printing the output of sample.py. It is just opening that file in Pycharm.

Sotos
  • 51,121
  • 6
  • 32
  • 66
  • You also have to call the python interpreter `python`, `python3` or which ever one you have, not only the path to the script as you are doing. –  Jun 27 '22 at 07:25
  • I created the virtual environment in python interpreter for python 3.10, still it is not working. – Neelam Jaiswal Jun 27 '22 at 08:41
  • Maybe this other [post](https://stackoverflow.com/questions/14838914/execute-os-systempython-inside-a-virtualenv) can help –  Jun 27 '22 at 08:51
  • My current environment is activated already, but still it is not working. – Neelam Jaiswal Jun 27 '22 at 09:26
  • When I install python 3.10 in the system, the above command is running properly, but as I install python 2.7, os.system is running on python 2.7. I set the path only for python 3.10 in environment variable, and also created the virtual environment only for 3.10 in Python interpreter, still it is taking python 2.7. In python IDLE, it is running fine, but in Pycharm, I'm facing this issue. What is the reason behind this? Please provide any solution. – Neelam Jaiswal Jun 30 '22 at 01:31
  • If the problem is in PyCharm, then you may want to look at how you have the interpreter setup in there. File -> Settings -> Project -> Python Interpreter. There you will find the path to the interperter used. Switch the path to the 3.10 version. –  Jun 30 '22 at 11:45

0 Answers0