Open dharris247networks opened 2 months 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).
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'
What does the following command show?
/usr/lib/python3.8 -m pip list
I get this! /usr/bin/python3.8: No module named pip
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.
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?
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).
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.
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:
conda => conda-libmamba-solver => conda
Brotli==1.0.9 conda-content-trust==0.2.0 └── cryptography [required: >=41, installed: 41.0.7] └── cffi [required: >=1.12, installed: 1.17.0] └── pycparser [required: Any, installed: 2.21] netbox-bgp==0.12.1 netbox-topology-views==3.9.1 netmiko==4.4.0 ├── cffi [required: >=1.17.0rc1, installed: 1.17.0] │ └── pycparser [required: Any, installed: 2.21] ├── ntc_templates [required: >=3.1.0, installed: 6.0.0] │ └── textfsm [required: >=1.1.0,<2.0.0, installed: 1.1.3] │ ├── future [required: Any, installed: 1.0.0] │ └── six [required: Any, installed: 1.16.0] ├── paramiko [required: >=2.9.5, installed: 3.4.1] │ ├── bcrypt [required: >=3.2, installed: 4.2.0] │ ├── cryptography [required: >=3.3, installed: 41.0.7] │ │ └── cffi [required: >=1.12, installed: 1.17.0] │ │ └── pycparser [required: Any, installed: 2.21] │ └── PyNaCl [required: >=1.5, installed: 1.5.0] │ └── cffi [required: >=1.4.1, installed: 1.17.0] │ └── pycparser [required: Any, installed: 2.21] ├── pyserial [required: >=3.3, installed: 3.5] ├── PyYAML [required: >=5.3, installed: 6.0.2] ├── scp [required: >=0.13.6, installed: 0.15.0] │ └── paramiko [required: Any, installed: 3.4.1] │ ├── bcrypt [required: >=3.2, installed: 4.2.0] │ ├── cryptography [required: >=3.3, installed: 41.0.7] │ │ └── cffi [required: >=1.12, installed: 1.17.0] │ │ └── pycparser [required: Any, installed: 2.21] │ └── PyNaCl [required: >=1.5, installed: 1.5.0] │ └── cffi [required: >=1.4.1, installed: 1.17.0] │ └── pycparser [required: Any, installed: 2.21] ├── setuptools [required: >=65.0.0, installed: 68.2.2] └── textfsm [required: >=1.1.3, installed: 1.1.3] ├── future [required: Any, installed: 1.0.0] └── six [required: Any, installed: 1.16.0] pipdeptree==2.23.1 ├── packaging [required: >=23.1, installed: 23.1] └── pip [required: >=23.1.2, installed: 23.3.1] pynetbox==7.3.3 ├── packaging [required: <24.0, installed: 23.1] └── requests [required: >=2.20.0,<3.0, installed: 2.31.0] ├── certifi [required: >=2017.4.17, installed: 2023.11.17] ├── charset-normalizer [required: >=2,<4, installed: 2.0.4] ├── idna [required: >=2.5,<4, installed: 3.4] └── urllib3 [required: >=1.21.1,<3, installed: 1.26.18] pyOpenSSL==23.2.0 └── cryptography [required: >=38.0.0,<42,!=40.0.1,!=40.0.0, installed: 41.0.7] └── cffi [required: >=1.12, installed: 1.17.0] └── pycparser [required: Any, installed: 2.21] PySocks==1.7.1 wheel==0.41.2
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