pythonpython-3.xpython-modulepython-venv

ModuleNotFoundError: No module named 'paramiko.auth_strategy' while using fab2 python


I'm trying to execute a python task using fab. I've installed fab2 for python3 and trying to use it to run the task in a venv. Unfortunately using fab2 keeps giving me this error:

(venv) My-MacBook-Pro-2:mypath myuser$ fab2
/mypath/venv/lib/python3.12/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "cipher": algorithms.TripleDES,
/mypath/venv/lib/python3.12/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "class": algorithms.TripleDES,
/mypath/fabfile.py:335: SyntaxWarning: "is" with 'str' literal. Did you mean "=="?
  if completeSql is 'Y':
Traceback (most recent call last):
  File "/mypath/venv/bin/fab2", line 8, in <module>
    sys.exit(program.run())
             ^^^^^^^^^^^^^
  File "/mypath/venv/lib/python3.12/site-packages/invoke/program.py", line 387, in run
    self.parse_collection()
  File "/mypath/venv/lib/python3.12/site-packages/invoke/program.py", line 479, in parse_collection
    self.load_collection()
  File "/mypath/venv/lib/python3.12/site-packages/fabric2/main.py", line 93, in load_collection
    super().load_collection()
  File "/mypath/venv/lib/python3.12/site-packages/invoke/program.py", line 716, in load_collection
    module, parent = loader.load(coll_name)
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "/mypath/venv/lib/python3.12/site-packages/invoke/loader.py", line 91, in load
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/mypath/fabfile.py", line 1, in <module>
    from fabric.api import env,hide,cd,settings,execute,task,runs_once, local, run, parallel, sudo
  File "/mypath/venv/lib/python3.12/site-packages/fabric/api.py", line 10, in <module>
    from fabric.context_managers import (cd, hide, settings, show, path, prefix,
  File "/mypath/venv/lib/python3.12/site-packages/fabric/context_managers.py", line 27, in <module>
    from fabric.state import output, win32, connections, env
  File "/mypath/venv/lib/python3.12/site-packages/fabric/state.py", line 9, in <module>
    from fabric.network import HostConnectionCache, ssh
  File "/mypath/venv/lib/python3.12/site-packages/fabric/network.py", line 14, in <module>
    from fabric.auth import get_password, set_password
  File "/mypath/venv/lib/python3.12/site-packages/fabric/auth.py", line 6, in <module>
    from paramiko.auth_strategy import (
ModuleNotFoundError: No module named 'paramiko.auth_strategy'

But when I try to install paramiko, I get:

$ pip install paramiko
Requirement already satisfied: paramiko in ./venv/lib/python3.12/site-packages (2.12.0)
Requirement already satisfied: bcrypt>=3.1.3 in ./venv/lib/python3.12/site-packages (from paramiko) (4.2.0)
Requirement already satisfied: cryptography>=2.5 in ./venv/lib/python3.12/site-packages (from paramiko) (43.0.0)
Requirement already satisfied: pynacl>=1.0.1 in ./venv/lib/python3.12/site-packages (from paramiko) (1.5.0)
Requirement already satisfied: six in ./venv/lib/python3.12/site-packages (from paramiko) (1.16.0)
Requirement already satisfied: cffi>=1.12 in ./venv/lib/python3.12/site-packages (from cryptography>=2.5->paramiko) (1.16.0)
Requirement already satisfied: pycparser in ./venv/lib/python3.12/site-packages (from cffi>=1.12->cryptography>=2.5->paramiko) (2.22)

I'm not sure if this is something to do with my python or fab. My python version is this:

$ python
Python 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin

and I'm running everything on venv. I'm also using fab2 instead of fab because fab kept giving me ModuleNotFoundError: No module named 'fabric.api' error and I could find no other solution. Any insights would be super helpful!


Solution

  • There is no module called fab2. I'm assuming you meant to use fabric2.