Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

QlikView forum consolidation is complete. Labels are now required. LEARN ABOUT LABELS
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Execute python script in load script


I am trying to run python script inside my load script in Qlik Sense app.

I know that I need to put OverrideScriptSecurity=1 in Settings.ini

I put

Execute py lib://python/getSolution.py 12 'ble';

and I get no error in qlik sense, bu script is not executed (I think) because inside the script I have

f = open("file.xml", "wb")



and file is not saved.

If I run script from terminal, then script is properly executed.

What could go wrong?

17 Replies

Just a question. Did you disable Standard Mode in Qlik Sense Desktop before trying to execute your Python script?

See: Disabling standard mode - Qlik Sense

Contributor III
Contributor III

Yes I did.

Contributor III
Contributor III

You were right. If I move script in C:\Windows\test.py it work.

Now I assume that the problem is space in path....

Any thoughts?

Thank you.


Put double-quotes around paths that you want to pass as-they-are (including any spaces) to an external program. Double-quotes will be passed along and won't be interpreted by the script engine in this case.

See this subthread for an explanation: Re: Double quotes on Execute statement

Contributor III
Contributor III

Most of these EXECUTE problems have to do with the fact that the Windows shell can't find the program to execute. Even cmd.exe may require a full path sepcification before it can be found.

Peter Cammaert's answer is most likely the correct one if you get the error message " Error: The handle is invalid."

Even if the execute command runs in QlikView Application on the server the executable may not be in the path for the service account running the qlikview distribution engine.

Check the system Path environment variable in Windows System Properties "Environment Variables"


I guess the problem is not with spaces but the directory is not accessible from qlik sense.


This works for me.


I have the following folders/files:





For QVW:

Go to Settings-->User Preferences-->Security and select the checkbox next to "Script (Allow Database Write and Execute Statements)"

In the load script editor Settings tab, select the checkbox next to "Can Execute External Programs"


QVW Load Script:

// Change path to python.exe per your local installation
EXECUTE D:\ProgramData\Anaconda3\python.exe "..\bin\testpython.py"
Python file:
# Open a file stream for writing
# assume data folder exists...if not, need to create for this call to work
f = open("../data/testpython.txt","w+")
# Write test content to file
f.write("this is a test...this is only a test...")
# Close file stream
Contributor III
Contributor III

I was able to get the below to work in qlik sense:
set vPyExe = C:\Program Files\Python37\python.exe;
set vPyScript = D:\...\PythonScript.py;

"$(vPyExe)" "$(vSource)"