Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'netmiko' #3485

Open
dharris247networks opened this issue Aug 22, 2024 · 8 comments
Open

ModuleNotFoundError: No module named 'netmiko' #3485

dharris247networks opened this issue Aug 22, 2024 · 8 comments

Comments

@dharris247networks
Copy link

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-libmamba-solver => conda => conda-libmamba-solver
  • 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

@ktbyers
Copy link
Owner

ktbyers commented Aug 22, 2024

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
Copy link
Author

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
Copy link
Owner

ktbyers commented Aug 23, 2024

What does the following command show?

/usr/lib/python3.8 -m pip list

@dharris247networks
Copy link
Author

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

@ktbyers
Copy link
Owner

ktbyers commented Aug 23, 2024

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
Copy link
Author

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
Copy link
Owner

ktbyers commented Aug 23, 2024

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
Copy link
Author

dharris247networks commented Aug 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants