SOLVED: Python activities - request for working script

#1

Solved July 5, 2019. Thanks! See post below.

Hi, I am having some trouble with Python. My workflow uses the following code:

C:\Users\burque505\AppData\Local\Programs\Python\Python37\python.exe
C:\Users\burque505\Documents\ZappySamples\burque505 Automations\Word2PDF1.pyw

A .png of the simple workflow is below.

(Although this script uses the pywin32 package, I have identical problems with a simple “hello, world!” script. I know Zappy has PDF activities, but this script was to test Python’s ability to do the same. Also, for reference, I have tried this workflow with Python 3.7, which is my system default, Python 3.6 64-bit, and Python 3.6 32-bit, changing the Zappy script to reflect the different executable location, python_request all with the same results.)

I can manually execute the script in the referenced directory success. Python (or I should say, Word, since it is doing the conversion) creates the PDF in the directory, and then closes as expected.

When Zappy runs the script, it reports that it has completed the task (via the message box and the built-in notification), but Word does not open and therefore no PDF is created.

I would be quite happy if I could have a workflow that, for example, uses Python to create a file in the script directory, appends some text, saves it and closes. Or any other simple script to demonstrate the proper paths and steps.

Thanks in advance, and kind regards,
burque505

EDIT: I have not yet installed all the dependencies, it seems. I have downloaded the Python Dependency Installer. There is a post regarding this here. I also did not look closely enough at the examples, or I would have seen the sample that (for me anyway) resides at “Documents\ZappySamples\PDFAutomations\PDFtoExcel”. I will report on my findings after I have my system properly set up.

Re-edit: I have ActiveState TCL and ghostscript installed, per the instructions given for manual installation of dependencies. I have Python 3.7 at “C:\Users\burque505\AppData\Local\Programs\Python\Python37\python.exe”. For the sample “PDFExtractUsingPython.zappy”, I have modified the file path to reflect my Python installation. The script runs without error, but no file is produced.

Re-edit 2: I have installed the PythonDependencyInstaller on a Win10 machine with Zappy. Unfortunately, my (non-)results above were duplicated.

Regards,
burque505

#2

Hii @burque505

If you want to create text file and write some text in the file, then follow below steps:

  1. Write Python Script Like
    image

  2. Make sure Python path is set in Environment variable

  3. After that Create Zappy Task like

image

And then Execute

Sample Files

PythonRunScript.zappy (2.4 KB)
Test.py (99 Bytes)

You can also use Run CMD Scripts to run python script on command line.
like,
image

Regards,
Vaishnavi

1 Like
#3

@vaishnavi, thanks for your help. Unfortunately, I have followed the instructions exactly as given, and the python scripts execute, but output nothing. The CMD scripts execute, and throw no error, but output nothing.
My path has python in the same location (with a different user name of course, which I changed in the script) as the supplied script.
I am running the 64-bit version of Zappy and 64-bit python 3.7. Could that perhaps make a difference?
Regards,
burque505

#4

64-bit version of Zappy and 64-bit python 3.7 should work with Zappy.
Can you Email us your Zappy and Python script file at team@zappy.ai?
Have you set the Environment variable?
Will look into this and get back to you.

1 Like
#5

Can you try running Zappy with admin privileges and see if this fixes the issue?

1 Like
#6

@ambujnew, I have been running with admin privileges already, thanks! So the results are the same.
Regards,
burque505

#7

@burque505
We checked your Run Python Script files in windows 10 as well as windows 7 64 bit, it works perfectly on our end with Zappy. So not sure what’s happening there.

One thing when you write python script and save it, make sure there is no space in naming of file.
eg: “Demopython.py” not like “Demo python.py”

About Run CMD Script :

Create batch file and write your command,Save it.

Enter the batch file path in front of “RunBatchFilePath” in Zappy task editor.

Go through follwing link for creation of batch file:

sample.bat (73 Bytes)

Regards,

Vaishnavi

#8

@vaishnavi , I still had no luck running python directly. I was, however, able get Run CMD Scripts to work like so:

    ` runas /user:YourUserName notepad.exe`

in the “Command” field.

And it worked for python scripts, by running something like:

runas /user:burque505 python.exe

in the “Command” field, and, e.g.,

C:\Users\burque505\Documents\ZappySamples\burque505\widgets_example_pyside.pyw

or similar in the “RunBatchFilePath” field (I’ve posted an image of my results for that script elsewhere in the forum). I sincerely hope nobody else has the problems I’m having with the python scripts and Run CMD Scripts, but if they do I expect they, like me, have only an admin account, and installed Zappy as admin.

Best regards,
burque505

#9

Thanks to the team for providing an installer to resolve my problems. Although there were some hiccups (almost all on Win7) I can now use both “Run CMD Scripts” and “Run Python Script” as intended (i.e. no “runas” necessary). Just for the record, although the provisional installer didn’t quite work on Win7, once I rebooted and reinstalled I was able to dispense with “runas.” On Win10, the provisional installer is working fine as an upgrade, with one caveat: I don’t know if others have the provisional installer or not, but if you install over the existing app (that is to say, upgrade) be sure to back up ZappySamples! Mine was overwritten. I did have backup, so all is well.

Thanks again for the service above and beyond the call of duty.
Regards,
Winter

#10

Zappy automatically creates a backup for the ZappySamples folder when you upgrade - you can find it in Documents -> OldZappySamples (this is your backed up ZappySamples before upgrade)