5

I am able to launch exe files from within QGIS actions without any problem, but when I try to launch one in particular (img2pdf.exe) I get an error.

Syntax error: invalid syntax

The command I am issuing is os.system("c:/img2pdf/img2pdf.exe"). Using that same format can successfully invoke other other exe.

If I open a command prompt and paste the exe file path into it, the application launches as expected.

What is the difference between launching from within a QGIS action and launching directly from the command line that could be causing img2pdf to fail?

Windows 10, QGIS 2.18.9-1.

3

Make sure you have the latest version of img2pdf.

Versions before 0.2.4 only run on Python 3, whereas QGIS 2.x uses Python 2.7.

If you still have the issue after verifying/updating, please update your question and show us the code of how you call the .exe from within QGIS.

Update after question clarification:
The error message you receive (and the location of it) very clearly means that you are using python 3.x code with a python 2.7 environment. I would still guess that it's most likely a problem with img2pdf relying on python 3.x code when it shouldn't. Try and raise an issue on their Github about this. When you run in from cmd, you run Python 3.x (which you probably have installed separately?).
It could also mean your system environment variables are shot, because you have two Python installations that might or might not have overriden the same settings (meaning some 2.x code tries loading 3.x code and vice versa).

I can't pinpoint the issue with that little error message, but I'm very sure that's the direction you need to look in.

  • Running img2pdf v 0.2.4. updated the question with the actual action text. Thank you! – Joebocop May 30 '17 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.