ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.55k stars 1.3k forks source link

ModuleNotFoundError: No module named 'netmiko' #3485

Open dharris247networks opened 3 weeks ago

dharris247networks commented 3 weeks ago

I am attempting to run a python script within Ubuntu 22.0.4. I have run the same script successfully from my windows machine but when I run from Ubuntu I get the following error: ModuleNotFoundError: No module named 'netmiko'. I have confirmed that the module is installed via the following: (base) dharris@netbox:~$ pip list Package Version


archspec 0.2.1 bcrypt 4.2.0 boltons 23.0.0 Brotli 1.0.9 certifi 2023.11.17 cffi 1.17.0 charset-normalizer 2.0.4 conda 23.11.0 conda-content-trust 0.2.0 conda-libmamba-solver 23.12.0 conda-package-handling 2.2.0 conda_package_streaming 0.9.0 cryptography 41.0.7 distro 1.8.0 future 1.0.0 idna 3.4 jsonpatch 1.32 jsonpointer 2.1 libmambapy 1.5.3 menuinst 2.0.1 netbox-bgp 0.12.1 netbox-topology-views 3.9.1 netmiko 4.4.0

(base) dharris@netbox:~$ pipdeptree Warning!!! Cyclic dependencies found:

I am looking for any assistance you might be able to give!

Relevant Python code

from netmiko import ConnectHandler from getpass import getpass import time, sys, getpass, paramiko

ktbyers commented 3 weeks ago

You need to post your full Python exception stack trace.

This type of issue is typically caused by using a different Python (i.e. the Python that you are executing is not the Python that Netmiko is installed in).

dharris247networks commented 2 weeks ago

Hello,

Thank you for your response. This is what I get when I use pdb:

(base) dharris@netbox:~$ python3 DAL1-FW1-Primary.py

/home/dharris/DAL1-FW1-Primary.py(3)() -> from netmiko import ConnectHandler (Pdb) (Pdb) n ModuleNotFoundError: No module named 'netmiko' /home/dharris/DAL1-FW1-Primary.py(3)() -> from netmiko import ConnectHandler (Pdb) n --Return-- /home/dharris/DAL1-FW1-Primary.py(3)()->None -> from netmiko import ConnectHandler (Pdb) n Traceback (most recent call last): File "DAL1-FW1-Primary.py", line 3, in --Call-- /usr/lib/python3.8/codecs.py(309)init() -> def init(self, errors='strict'): (Pdb) n /usr/lib/python3.8/codecs.py(310)init() -> IncrementalDecoder.init(self, errors) (Pdb) n /usr/lib/python3.8/codecs.py(312)init() -> self.buffer = b"" (Pdb) n --Return-- /usr/lib/python3.8/codecs.py(312)init()->None -> self.buffer = b"" (Pdb) n --Call-- /usr/lib/python3.8/codecs.py(331)getstate() -> def getstate(self): (Pdb) n /usr/lib/python3.8/codecs.py(333)getstate() -> return (self.buffer, 0) (Pdb) n --Return-- /usr/lib/python3.8/codecs.py(333)getstate()->(b'', 0) -> return (self.buffer, 0) (Pdb) n --Call-- /usr/lib/python3.8/codecs.py(319)decode() -> def decode(self, input, final=False): (Pdb) n /usr/lib/python3.8/codecs.py(321)decode() -> data = self.buffer + input (Pdb) n /usr/lib/python3.8/codecs.py(322)decode() -> (result, consumed) = self._buffer_decode(data, self.errors, final) (Pdb) n /usr/lib/python3.8/codecs.py(324)decode() -> self.buffer = data[consumed:] (Pdb) n /usr/lib/python3.8/codecs.py(325)decode() -> return result (Pdb) n --Return-- /usr/lib/python3.8/codecs.py(325)decode()->'import pdb\n...isconnect()\n' -> return result (Pdb) n from netmiko import ConnectHandler ModuleNotFoundError: No module named 'netmiko'

ktbyers commented 2 weeks ago

What does the following command show?

/usr/lib/python3.8 -m pip list
dharris247networks commented 2 weeks ago

I get this! /usr/bin/python3.8: No module named pip

ktbyers commented 2 weeks ago

Okay...so whatever pip you are using in the first command is not the Python that you are actually executing.

For the Python that you are executing, you have not installed Netmiko.

dharris247networks commented 2 weeks ago

I appreciate the help! I think you are correct. It appears that Netmiko is installed for version 3.11. Is there a way to install python for a specific version. Like if I want to use python3.8 how can I install netmiko specifically for python3.8?

ktbyers commented 2 weeks ago

Fix your no pip issue and then just python3.8 -m pip install netmiko (though you really should create a Python virtual environment and use that Python instead).

dharris247networks commented 2 weeks ago

Awesome! Using the Python virtual environment resolved my issue.

Thank you for the assistance!

[signature_1084828966]http://www.247networks.com/

Demetrius Harris / Consulting Engineer 24/7 Networks, Inc

116 Inverness Dr. E, #200, Englewood, CO 80112

720.881.3217 | @.**@.>

Confidentiality Note: This email may contain confidential and/or private information. If you received this email in error please delete and notify sender

@.?anonymous&ep=signature> Book time to meet with @.?anonymous&ep=signature>


From: Kirk Byers @.> Sent: Friday, August 23, 2024 11:49 AM To: ktbyers/netmiko @.> Cc: Demetrius Harris @.>; Author @.> Subject: Re: [ktbyers/netmiko] ModuleNotFoundError: No module named 'netmiko' (Issue #3485)

EXTERNAL: This email originated from outside the organization. Use your best judgement, and if unsure, ask!

Fix your no pip issue and then just python3.8 -m pip install netmiko (though you really should create a Python virtual environment and use that Python instead).

— Reply to this email directly, view it on GitHubhttps://github.com/ktbyers/netmiko/issues/3485#issuecomment-2307543453, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BILW5XO2VYTAIJOU5QHM673ZS5YZ5AVCNFSM6AAAAABM63LSQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXGU2DGNBVGM. You are receiving this because you authored the thread.