Forum Archive

Problems with netmiko and pythonista

[deleted]

Hi All

I have successfully installed netmiko using slash but when trying to run a script to connect to my cisco device (wlc) I am getting the following error (traceback )

Iphone 12.0.1 with pythonista 3

Copy of the script below

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from netmiko import ConnectHandler

TEST = {
    'device_type': 'cisco_wlc',
    'ip':   '<ip>',
    'username': '<username>',
    'password': '<password>',
    'port' : 22,          # optional, defaults to 22
    'global_delay_factor': 4,
}
net_connect = ConnectHandler(**TEST)

output = net_connect.send_command('config wlan disable 2')

Traceback

don't know how to enumerate ttys on this system.
! I you know how the serial ports are named send this information to
! the author of this module:

sys.platform = 'ios'
os.name = 'posix'
pySerial version = 3.4

also add the naming scheme of the serial ports and with a bit luck you can get
this module running...
Traceback (most recent call last):
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/disable_controller_AP.py", line 3, in <module>
    from netmiko import ConnectHandler
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/__init__.py", line 8, in <module>
    from netmiko.ssh_dispatcher import ConnectHandler
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/ssh_dispatcher.py", line 4, in <module>
    from netmiko.a10 import A10SSH
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/a10/__init__.py", line 2, in <module>
    from netmiko.a10.a10_ssh import A10SSH
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/a10/a10_ssh.py", line 4, in <module>
    from netmiko.cisco_base_connection import CiscoSSHConnection
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/cisco_base_connection.py", line 3, in <module>
    from netmiko.base_connection import BaseConnection
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/base_connection.py", line 28, in <module>
    from netmiko.utilities import write_bytes, check_serial_port, get_structured_data
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/netmiko/utilities.py", line 8, in <module>
    import serial.tools.list_ports
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/serial/tools/list_ports.py", line 29, in <module>
    from serial.tools.list_ports_posix import comports
  File "/private/var/mobile/Containers/Shared/AppGroup/954EE244-FE4F-4160-9E96-DA83702F48DB/Pythonista3/Documents/site-packages-3/serial/tools/list_ports_posix.py", line 112, in <module>
    raise ImportError("Sorry: no implementation for your platform ('{}') available".format(os.name))
ImportError: Sorry: no implementation for your platform ('posix') available

The same script works fine on my mac (after installing netmiko via pip)

JonB

The error message is remarkably clear -- netmiko doesn't know how iOS serial ports are named. You should be able to go into the module that is raising the error, and find where it looks for the platform. Likely your can just use the same convention as macos... You are not going to be using com ports so u don't think it matters...

_baiyun

I am having this issue. What did you do to solve it? I don't really need serial tool for my scripts. I don't believe that is the main functionality of netmiko so it is odd it tries to import that anyways.