Call to Python Version

On an Enterprise server that has multiple versions of Python installed, we’re getting an error when trying to run some Python 3 processes. The suspicion is that Panorama and Python 3 are running in different shells and that Panorama is calling to the wrong version of Python for our purposes here.

Is there a way to specify the version of Python that a script refers to?

Panorama normally uses the version of Python that is in


If you want to use a version of Python that is installed in a different location, use this code:

secretglobal pythonPrefixLineTemplate
pythonPrefixLineTemplate = "#!/some/where/else/python"

FYI, the source code for the PYTHON statement is viewable (and even editable). In Panorama 6 that is done with the Custom Statements wizard, PYTHON is in _ScriptLib.

Additional note: None of this has anything to do with what shell is being used. DIfferent shells could have different search path’s for finding shell commands, but since Panorama is explicitly specifying the exact path to use, the search path preference doesn’t matter. It could matter if you were manually invoking a command from

1 Like

Thank You, that’s very helpful

Panorama is not pointing to the right version of Python as 3.9 is not in /usr/bin/, but I can’t find _ScriptLib in any installation of Panorama 6. Can you (or anybody) send me a copy please?

Sorry, it’s in _ScriptLib in PanoramaX. In Panorama 6 the PYTHON statement is in _UtilityLib.

However, you don’t need to view or edit this statement, just use the code I posted above before the first time you use the PYTHON statement.

I would prefer to just make one statement for the entire server to change it so the _UtilityLib method sound most appealing.

Thanks, this has been driving me nuts trying to figure out why scripts that work fine outside of Panorama, get errors when used inside of it.

I actually wasn’t suggesting changing _UtilityLib, but that’s pretty safe to do since ProVUE will never be publishing another version of Panorama 6. The change is different than the code I posted above but I don’t think you’ll have any problem figuring it out.

Here is what I wrote and I get the “Cannot compile procedure - one or more incorrect steps”
when I put it in.

secretglobal pythonPrefixLineTemplate
pythonPrefixLineTemplate = “”#!/usr/local/bin/python3.9""

It compiles fine with single quotes and now runs properly, but we get the error"
ImportError: No module named ‘jwt’

The same code runs fine via the terminal. It is only in Panorama that we get the error.

I don’t know how on earth I got two quotes in there, that was a mistake on my part. I have gone back and edited the post above.

But as I said – DO NOT use that code when editing the PYTHON procedure in _UtilityLib. Instead, find where the code is that sets up the pythonPrefixLineTemplate variable and change it there. Here’s the line you want to change:

define pythonPrefixLineTemplate,"#!/usr/bin/python"

No matter what path we enter it runs Python 2.7

;python version check
Global ScriptResult
secretglobal pythonPrefixLineTemplate
;pythonPrefixLineTemplate = “#!/usr/local/bin/python3”
;pythonPrefixLineTemplate = “#!/Library/Frameworks/Python.framework/Versions/3.9/python”
;pythonPrefixLineTemplate = “#!/usr/bin/python”
pythonPrefixLineTemplate = “#!/usr/local/bin/python”

python |||
import os, sys

Message ScriptResult

Well I’m not a shell expert or a Python export. You now have the keys to control the horizontal and the vertical, so I’ll leave it to you. Let us know if you figure it out.

Understood, and thanks for the help you provided.

We’ve had zero luck. It always goes to 2.7 in Panorama. Same script runs great on Python 3 in Terminal.

It seems like the only possible solution is to run completely externally such as in a shell script

Since you have access to the PYTHON procedure source code, there absolutely must be a way to do it.

For that matter, the PYTHON statement is just a convenience. You can run arbitrary shell scripts with the SHELLSCRIPT statement.

We were able to reliably run the script through Python 3 via Terminal but could never get Pan 6 to do it. Possibly it was our failure to put it together properly but what worked in Terminal didn’t work as a shell script in Panorama. Eventually we ended up saving the Python script to disk, then having AppleScript run it and that’s working.

Well for what it’s worth – that’s exactly what Panorama does to run Python scripts! Except are you saying that your AppleScript somehow opens and runs it there? Panorama uses the AppleScript do shell script command, which is built into AppleScript.

We had problems calling the script no matter how we did it. We used the same pathway we got when the ran it it Terminal.


Turns out that that was a problem when calling from Panorama. Terminal escaped the ~. When we removed it:


things worked fine with SHELLSCRIPT as long as the file was set to be an executable with:

chmod +x /\~sites/apns/