
09-25-2020, 03:13 PM
|
 |
VanDyke Technical Support
|
|
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
|
|
How-To: Use Python 3.8 with SecureCRT v9.0 for Windows
New (beginning in version 9.0), SecureCRT on the Windows platform supports the use of a third party python v3.8 scripting engine.
Here are some tips to help you get started with using a Python 3.8 scripting engine in SecureCRT:
- Install SecureCRT 9.0 or newer.
The ability to use a third party python non-windows-native and non-embedded python scripting engine is functionality that is new to SecureCRT starting with version 9.0.
- Install a python 3.8 scripting engine.
The python 3.8 scripting engine from python.org is recommended: https://www.python.org/downloads/windows/.
See the "Python installation notes" section below for details.
NOTES:- SecureCRT 9.0 supports the use of an external Python 3.8.x engine to automate SecureCRT functionality internal to SecureCRT (i.e. only when the script is run within SecureCRT via Script / Run... for example).
- The external python engine must be 3.8.x -- no other external python 3 versions are supported in SecureCRT 9.0.
- While using an external Python 3.8.x engine to run scripts within SecureCRT it may be possible to interface with Python libraries that are not native to that external Python 3.8.x environment; however, VanDyke Software does not test SecureCRT for or guarantee compatibility with any specific Python libraries.
- Make sure you download the python v3.8 installer that matches the "bitness" of the SecureCRT that you have installed. For example, if you have the 64-bit version of SecureCRT installed, you must install the 64-bit version of python; if you have the 32-bit version of SecureCRT installed, you must install the 32-bit version of python.

Question:
How do I know if the SecureCRT I am running is the 32-bit or 64-bit version?
Answer:
Look in the "About SecureCRT" window.- If the version seen there shows (x64 ...), then a 64-bit SecureCRT is running.
- If the version seen doesn't show (x64 ...), then a 32-bit SecureCRT is running.
Question:
How do I know if the python installer I downloaded is a 32-bit or 64-bit version?
Answer:
Typically the python.org installers will have "amd64" as part of the installer name if it's the 64-bit version. For example (64-bit): python-3.8.6-amd64.exe
If you downloaded an installer that doesn't have "amd64" in the name, it's probably the 32-bit version. For example (32-bit): python-3.8.6.exe
Python installation notes
When installing python, you should enable the Add ... to PATH option so that SecureCRT will be able to find the python38.dll file for loading.
NOTE:
If you fail to enable the Add Python 3.8 to PATH option, SecureCRT won't be able to find the Python 3 script engine.
Then, when you try to run a Python 3 script, SecureCRT will have no other option but to report: "Unable to load the Python scripting engine."
 If you forget to have the python installer add itself to the PATH environment variable, you can do it manually within Windows for your user account.
Can I use the Anaconda script engine instead?
While it is recommended that you use the python.org script engine, if you want to use Anaconda as your script engine...- You may need to edit the PATH environment variable for your Windows user account to point to the Anaconda installation directory. For example:
C:\ProgramData\Anaconda3
- You may also need to set the PYTHONPATH environment variable with a value which points to the Lib sub-directory in the Anaconda directory. For example:
C:\ProgramData\Anaconda3\Lib
- You must be using SecureCRT Version 9.0.0.2331 or newer
- Use "Python3" as your scripting language in your SecureCRT script file header.
For example:
Code:
# $language = "Python3"
# $interface = "1.0"
import sys
import platform
crt.Dialog.MessageBox(
"sys.version_info:\r\n{}\r\n\r\nsys.version:\r\n{}\r\n\r\nsys.hexversion:\r\n{}\r\n\r\nplatform.python_version:\r\n{}".format(
sys.version_info,
sys.version,
sys.hexversion,
platform.python_version()))
The above code, when run in SecureCRT 9.0 after a successful python 3 engine installation, will generate a window like this:
Notes:- If you want to continue using the python 2.7.x scripting engine that comes with SecureCRT, there's no need to change anything.
- If you want to force the use of the python 3.8 scripting engine for all of your SecureCRT scripts, without having to specify the language as "Python3" in the script header, simply rename/remove the vPython* files located in SecureCRT's program files install folder (you'll have to close SecureCRT first).
Last edited by jdev; 08-18-2021 at 02:18 PM.
Reason: Add extra emphasis to highlight need to enable the 'Add Python 3.8 to Path' option in the Python installer.
|