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, use where python
to get the full path and use it when calling os.system
, for example:
os.system("c:\pythons7\python script2 -param1 ..")
(BTW - It is recommended to replace os.system
with subprocess.call
or some other subprocess function)