
09-25-2020, 04:13 PM
|
 |
VanDyke Technical Support
|
|
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,047
|
|
How-To: Use Python 3 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 scripting engine; it means that you can use Python 3, if desired.
Here are some tips to help you get started with using a Python 3 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 scripting engine. The python 3 scripting engine from python.org is recommended: https://www.python.org/downloads/windows/
NOTE: Make sure you download the python 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. 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 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 bgagnon; 11-05-2020 at 10:16 AM.
Reason: Sentence did not make sense: How...SCRT you're running ... to SCRT I am running ...
|