Installed netmiko in PyCharm but PyCharm failed to execute netmiko for SSH connection


Installed netmiko in PyCharm successfully, but when write code to import netmiko, it doesn't take effect. Meanwhile executing the code with iPhython, everything works fine. I did add netmiko path to PyCharm project interpreter to point to 'netmiko-cfg', 'netmiko-grep' and 'netmiko-show' but still my code can't be executed.

from getpass import getpass

my_device = {
'password': getpass(),
'global_delay_factor': 2,

net_connect = Netmiko(**my_device)

# delay time multiple by 2
output = net_connect.send_command("copy run start", delay_factor=2)


Code output:


Traceback (most recent call last):
File "/Users/Sean/Sites/project2/", line 2, in <module>
from netmiko import ConnectHandler
File "/Users/Sean/Envs/project2/lib/python2.7/site-packages/netmiko/", line 8, in <module>
from netmiko.ssh_dispatcher import ConnectHandler
File "/Users/Sean/Envs/project2/lib/python2.7/site-packages/netmiko/", line 4, in <module>
from netmiko.a10 import A10SSH
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/netmiko/a10/", line 2, in <module>
from netmiko.a10.a10_ssh import A10SSH
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/netmiko/a10/", line 4, in <module>
from netmiko.cisco_base_connection import CiscoSSHConnection
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/netmiko/", line 3, in <module>
from netmiko.base_connection import BaseConnection
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/netmiko/", line 13, in <module>
import paramiko
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/paramiko/", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/paramiko/", line 37, in <module>
from paramiko import util
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/paramiko/", line 32, in <module>
from paramiko.common import DEBUG, zero_byte, xffffffff, max_byte
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/paramiko/", line 23, in <module>
from paramiko.py3compat import byte_chr, PY2, bytes_types, text_type, long
File "/Users/ABC/Envs/project2/lib/python2.7/site-packages/paramiko/", line 2, in <module>
import base64
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 98, in <module>
_urlsafe_encode_translation = string.maketrans(b'+/', b'-_')
AttributeError: 'module' object has no attribute 'maketrans'

Process finished with exit code 1



Comment actions Permalink

Hi Seanche,

I'm getting the same problem. I can't execute netmiko from Pycharm. Nevertheless, the same code is working if I execute it from Python console outside Pycharm.

Did you manage to get it fixed?


Comment actions Permalink

Hi, try to disable

  • Add content roots to PYTHONPATH
  • Add source roots to PYTHONPATH

options in the Run Configuration you are using to execute the code. It looks like you have a namespace collision due to a custom module/package called string.

Comment actions Permalink

Thanks for the answer, Pavel.

Unfortunately that didn't solved the problem. I'm still getting this errors when python execute netmiko ConnectHandler.

By the way, I've configured Pycharm to use the system interpreter in my linux machine.

These are the errors I'm getting:

Traceback (most recent call last):
  File "/home/amarcos/PycharmProjects/Testing2/", line 24, in <module>
    net_connect = netmiko.ConnectHandler(**device)
  File "/home/amarcos/.local/lib/python2.7/site-packages/netmiko/", line 190, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/amarcos/.local/lib/python2.7/site-packages/netmiko/", line 245, in __init__
  File "/home/amarcos/.local/lib/python2.7/site-packages/netmiko/", line 743, in establish_connection
    raise NetMikoTimeoutException(msg)
netmiko.ssh_exception.NetMikoTimeoutException: Connection to device timed-out: cisco_ios

Process finished with exit code 1



Comment actions Permalink

This is a different error than in the original case, you have another problem.

>Nevertheless, the same code is working if I execute it from Python console outside Pycharm

Make sure you use the same interpreter in PyCharm and in the console outside of it. At the moment it looks like a netmiko problem ( not a PyCharm bug.

Comment actions Permalink

Click the help icon and it should give you the option to install netmiko


Please sign in to leave a comment.