VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Python netmiko (https://forums.vandyke.com/showthread.php?t=12579)

asamue 01-19-2017 12:57 PM

Python netmiko
 
Hi
I'm trying to import netmiko module to secure crt 8.0.4 python 2,7 installation but I can't get it to work.
Can anyone explain how to do it with secure crt
I have no problem running netmiko in my normal python 2.7 installation but I want to use the the one that is built.

jdev 01-19-2017 01:27 PM

SecureCRT's built-in python interpreter is a somewhat of a bare-bones python environment and does not support importing all possible modules that could exist.

My guess is the netmiko module you're trying to import depends on another module that is not part of SecureCRT's bare-bones python environment.

What does "can't get it to work" specifically look like for you?

For example, what specific error(s) are you seeing when your code attempts to import netmiko?

--Jake

asamue 01-20-2017 01:01 AM

When you install Netmiko in a "stand alone" python installation, you do it with "python setup.py install" where setup.py is netmikos setup file.
I can't find a way of doing this with secure crt ( and maybe you can't do it thaty way)
I have tried to copy the modules that I need but I can't get it to work even though I have modified the sys.path to point to the correct module.

Is there a way of having secure crt to call an external python installation instead of using the one built in?

jdev 01-20-2017 12:29 PM

Quote:

Originally Posted by asamue (Post 46884)
When you install Netmiko in a "stand alone" python installation, you do it with "python setup.py install" where setup.py is netmikos setup file. I can't find a way of doing this with secure crt (and maybe you can't do it that way)

You're absolutely right. You cannot import a module like this into SecureCRT's built-in python environment.

Quote:

Is there a way of having secure crt to call an external python installation instead of using the one built in?
If you're using a version of SecureCRT 8.0.1 and earlier, you can use an external python installation by renaming the python27.dll and python27.zip files (found in SecureCRT's program files location) to something like python27-do_not_use.dll and python27_do_not_use.zip.

However, as of SecureCRT version 8.0.2 and later, this is not possible because a change was made in SecureCRT to only load its own built-in python engine.

I've added a feature request on your behalf to allow SecureCRT to load/use an external python installation. Should this ever be possible in the future, we'll be sure to post here and let you know.

--Jake

kevin.p.ross 07-16-2019 11:48 AM

Other modules available
 
I'm attempting to script a callout to return OUI manufacturer info (this is in a Windows installation). The example script for GoogleSelectedText does work and launches a browser window with the answer using the webrowser module. I'd like to keep it all within SecureCRT though, and tried using urllib.request, but get the error "The specified module could not be found.".

As a new and exploring python script writer here, I was wondering if there is an available list of the modules included in the bare-bones python included in SecureCRT.

Also, any recommendation for making a similar call within the available library?

Thanks,
Kevin

bgagnon 07-16-2019 02:16 PM

Hi Kevin,

If you open (for viewing) the vpython27.zip file included in SecureCRT's installation directory, you will see the included modules. However, there won't likely be any modules/libraries that will provide network/TCP access; those are generally not available in the minimal Python environment that comes with SecureCRT. In addition, there may be libraries that are included with SecureCRT's Python environment that won't work because the _socket module is not present. (Support for that is a feature request and I've added this thread to that.)

kevin.p.ross 07-16-2019 05:06 PM

Thanks Brenda for the quick response. I'll check that out and stick with the webbrowser call for now, it gets me the info I'm looking for.:)

tazdrum73 04-27-2020 01:19 PM

reference to external python installation
 
Hi,

Has this issue been resolved? I would like to know if there is a way to import/refer to external python modules?

Thanks,

Rich

bgagnon 04-27-2020 02:08 PM

Hi Rich,

What module(s) do you want supported?

bgagnon 09-29-2020 12:33 PM

Hi all,

I wanted to let you know the __socket (and other) modules should be available as of SecureCRT v9.0, currently in beta 1 release, since this support was added:

Changes in SecureCRT 9.0 (Beta 1) -- September 24, 2020
-------------------------------------------------------
New Features:

  • Windows: Added support for Python 3. Python 3.8(available at python.org) must be installed and the script's first line must be: # $language = "python3". Since support for Python 3 is provided through an external module, Python 3 libraries can be used in SecureCRT scripts.

Note that this is Windows only support at this time. In fact, we released beta 1 installers *only* for Windows. We hope to include all platforms in later releases.


All times are GMT -6. The time now is 10:02 PM.