导入模块|内美子

时间:2018-06-28 16:12:57

标签: import module

我是编程新手,正在尝试弄清楚如何在Python中使用模块。具体来说,我正在尝试安装netmiko以实现网络可编程性。但是它似乎不起作用。

我正在使用OSX High-Sierra,并使用pip install netmiko安装了netmiko:

Requirement already satisfied: netmiko in /Library/Python/2.7/site-packages (2.1.1)
Requirement already satisfied: paramiko>=2.0.0 in /Library/Python/2.7/site-packages (from netmiko) (2.4.1)
Requirement already satisfied: scp>=0.10.0 in /Library/Python/2.7/site-packages (from netmiko) (0.11.0)
Requirement already satisfied: pyyaml in /Library/Python/2.7/site-packages (from netmiko) (4.1)
Requirement already satisfied: pyserial in /Library/Python/2.7/site-packages (from netmiko) (3.4)
Requirement already satisfied: textfsm in /Library/Python/2.7/site-packages (from netmiko) (0.4.1)
Requirement already satisfied: pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko>=2.0.0->netmiko) (0.4.3)
Requirement already satisfied: bcrypt>=3.1.3 in /Library/Python/2.7/site-packages (from paramiko>=2.0.0->netmiko) (3.1.4)
Requirement already satisfied: cryptography>=1.5 in /Library/Python/2.7/site-packages (from paramiko>=2.0.0->netmiko) (2.2.2)
Requirement already satisfied: pynacl>=1.0.1 in /Library/Python/2.7/site-packages (from paramiko>=2.0.0->netmiko) (1.2.1)
Requirement already satisfied: six>=1.4.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from bcrypt>=3.1.3->paramiko>=2.0.0->netmiko) (1.4.1)
Requirement already satisfied: cffi>=1.1 in /Library/Python/2.7/site-packages (from bcrypt>=3.1.3->paramiko>=2.0.0->netmiko) (1.11.5)
Requirement already satisfied: enum34; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography>=1.5->paramiko>=2.0.0->netmiko) (1.1.6)
Requirement already satisfied: idna>=2.1 in /Library/Python/2.7/site-packages (from cryptography>=1.5->paramiko>=2.0.0->netmiko) (2.7)
Requirement already satisfied: asn1crypto>=0.21.0 in /Library/Python/2.7/site-packages (from cryptography>=1.5->paramiko>=2.0.0->netmiko) (0.24.0)
Requirement already satisfied: ipaddress; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography>=1.5->paramiko>=2.0.0->netmiko) (1.0.22)
Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko>=2.0.0->netmiko) (2.18)

它似乎已经安装了,但是当我尝试在IDLE中使用它时,似乎无法识别它。

  

>>>导入Netmiko Traceback(最近一次通话):文件   “”,第1行,在       导入Netmiko ModuleNotFoundError:没有名为“ Netmiko”的模块

我在做什么错?我看到它无法识别该模块,但是如何使它工作呢?

1 个答案:

答案 0 :(得分:0)

正如其他人提到的那样,您必须从自由的netmiko(带有小写的N)中导入带有大写N的Netmiko:

从netmiko导入Netmiko

这是一个有关如何使用Netmiko在cisco交换机上执行一些show commandos的示例:

https://github.com/aboyum/Netmiko-showcommand/blob/master/netmiko.py