devdacool devdacool - 1 year ago 255
Python Question

Compiled Python script "No handlers could be found for logger "paramiko.transport"

My problem is very similar to this question already asked:
No handlers could be found for logger paramiko

The difference is that my script will run perfectly fine in the Python interpreter but will throw the mentioned error when compiled with PyInstaller to an exe file. I have tried a couple different logging handlers with no luck, and I'm shooting for a self-containted executable I can run from any Windows system. Here is my script for reference:

from netmiko import ConnectHandler
net_connect = ConnectHandler(device_type='hp_procurve', ip='', username='myusername', password='mypassword')
output = net_connect.send_command("show run")
print output
raw_input("Press enter to exit...")

Thanks for the help!

Answer Source

Add a console handler (for example) to paramiko.transport:

paramiko_logger = logging.getLogger('paramiko.transport')
if not paramiko_logger.handlers:
    console_handler = logging.StreamHandler()
        logging.Formatter('%(asctime)s | %(levelname)-8s| PARAMIKO: '
                          '%(lineno)03d@%(module)-10s| %(message)s')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download