VanDyke Software

Tips

Index

How to Use Python 3.8 with SecureCRT 9.0 for Windows

Beginning in version 9.0, SecureCRT on the Windows platform supports the use of a third party Python 3.8 scripting engine.

Here are some tips to help you get started with using a Python 3.8 scripting engine in SecureCRT.

  1. 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.
  2. 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 3.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
      • You must be using SecureCRT Version 9.0.0.2331 or newer

  3. Use "Python3" as your scripting language in your SecureCRT script file header.
    For example:
    # $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).

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.