I am building a QGIS plugin with Python (3.7) that is supposed to run a shell command.
This command launches an FME Script with some parameters
os.system("fme D:\script.fmw --param1 D:\file.txt --param2 value")
When i run this command on my python plugin main script, there is no effect.
But when i run the same command in a shell, it works. When i run it from a regular python script, it works too.
I also tried using subprocess
module to get more information on my result. It raises a compilation error with code 1.
2 Answers 2
I'm not really up on Python, but I see you're not including the full path to the FME executable. Could that be the issue? i.e. it can't find FME
It's also good practice to do if you have multiple FME versions installed (I know a lot of users who do that) because depending on the PATH the wrong version might get run.
I had the same issue and I finally solved it.
Try to check the current path localisation on the QGIS Python Console with
os.getcwd()
Mine was systeme32, so no wonder why it won't let me do system commands. I changed it with:
os.chdir(mypath)
and then everything worked.