【问题标题】:Netmiko - Windows 10 - SSH Router - Not able to run 1st command onlyNetmiko - Windows 10 - SSH 路由器 - 不能只运行第一个命令
【发布时间】:2020-02-20 07:41:22
【问题描述】:
>>> from netmiko import ConnectHandler

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\netmiko\__init__.py", line 7, in <module>

各位专家,

从 netmiko 导入 ConnectHandler 命令后应用我遇到了上述错误。

设置 - 已安装 Windows 10、Python 3.7、Netmiko。电脑中没有其他名为 netmiko.py 的文件。

请提出解决方案。

【问题讨论】:

    标签: ssh router cisco netmiko


    【解决方案1】:

    要使用 Netmiko,您需要在安装 netmiko 的同一 python 环境中。

    我看到您安装了 Windows 10 和 Python 3.7,但用于调用 Netmiko 的 Python 是 2.7。从目录名C:\Python27\lib\site-packages\netmiko\__init__.py中的“Python27”可以看出。

    运行 Python 3.7 shell 并再次尝试该命令。确保 Netmiko 已正确安装在环境中。

    要验证是否已安装 netmiko,请键入 help("modules") 以检索所有已安装软件包的列表。如果 Netmiko 已正确安装,您应该会在那里看到它。

    Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> help("modules")
    
    Please wait a moment while I gather a list of all available modules...
    
                          ---- output omitted ----
    
    Cryptodome          bdb                 gc                  pyexpat
    __future__          binascii            genericpath         pygments
    _string             codecs              netaddr             tabnanny
    _strptime           codeop              netapp              tarfile
    _struct             collections         netmiko             telnetlib
    _symtable           colorama            netmiko_globals     tempfile
    _testbuffer         colorsys            netrc               terminal_server
    _testcapi           compileall          nntplib             test
    _testconsole        concurrent          nt                  textfsm
    _testimportmultiple configparser        ntpath              textwrap
    _testmultiphase     contextlib          nturl2path          this
    _textfsm            contextvars         numbers             threading
    

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      运行:python3 以访问 python 版本 3.5+ 终端。

      >>>from netmiko import ConnectHandler
      

      【讨论】:

        最近更新 更多