I'm building in Pycharm a script (let's call it script1) that calls another script (let's call it script2) that take parameters as input
script2 is using in it xlrd (import xlrd)
when I run script2 manually and give it the needed parameters, it works very well
script1, calls script2 (using os.system()) as follow:
os.system("python script2 -param1 ..")
and I get this error:
from file script2
import xlrd
ImportError: No module named 'xlrd'
does anyone know how to fix it ? or make it work correctly ?
I made sure of the parameters I give as input, they are right and xlrd is defined in project interpreter
Thanks a lot
You are probably calling the wrong python. If running
python script2...from the command line works, usewhere pythonto get the full path and use it when callingos.system, for example:(BTW - It is recommended to replace
os.systemwithsubprocess.callor some other subprocess function)