{"id":23699,"library":"fabric2","title":"Fabric (v2/v3)","description":"High-level Python library for SSH command execution and system administration, built on top of Invoke. The current version is 3.2.3 (2024-08). Fabric v2+ is a ground-up rewrite; it is incompatible with the original Fabric 1.x. The library uses an active, though slow, release cadence.","status":"active","version":"3.2.3","language":"python","source_language":"en","source_url":"https://github.com/fabric/fabric","tags":["ssh","remote execution","deployment","automation","fabric"],"install":[{"cmd":"pip install fabric","lang":"bash","label":"Install fabric"}],"dependencies":[{"reason":"Used for task execution and CLI","package":"invoke","optional":false},{"reason":"SSH protocol implementation","package":"paramiko","optional":false},{"reason":"Required by paramiko for crypto","package":"cryptography","optional":false}],"imports":[{"note":"fabric API, not fabric2. This is correct.","wrong":"from fabric import Connection","symbol":"Connection","correct":"from fabric import Connection"},{"note":"In v2+ decorators moved to invoke","wrong":"from fabric.decorators import task","symbol":"task","correct":"from invoke import task"}],"quickstart":{"code":"from fabric import Connection\n\n# Replace with your host/user/password or use SSH key\nc = Connection(host='example.com', user='myuser', connect_kwargs={'password': os.environ.get('PASSWORD', '')})\nresult = c.run('whoami')\nprint(result.stdout.strip())","lang":"python","description":"Basic remote command execution using Fabric's Connection object. Replace auth with your own credentials."},"warnings":[{"fix":"Use `from fabric import Connection`, `from invoke import task`. Run tasks with `invoke` CLI.","message":"Fabric v2/v3 is a complete rewrite of Fabric 1.x. No backward compatibility. Do not import `fabric.api`, `fabric.decorators`, or use `fab` command.","severity":"breaking","affected_versions":">= 2.0"},{"fix":"Upgrade to fabric >=2 and rewrite code as per new API.","message":"The original Fabric 1.x (fabric<2) is unmaintained. The PyPI package name is now 'fabric', but legacy users might install 'fabric2' (which redirects).","severity":"deprecated","affected_versions":"< 2.0"},{"fix":"Access stdout via `result.stdout` or use str cast: `str(result)`. Also check `result.exited` for exit code.","message":"The `run()` method returns a `Result` object, not a string. Many newcomers try to use the result as a string directly.","severity":"gotcha","affected_versions":">= 2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from fabric import Connection` (not `from fabric.connection import Connection`).","cause":"Trying to import `Connection` from the wrong submodule (e.g., `fabric.connection` instead of `fabric`).","error":"KeyError: 'Connection'"},{"fix":"Replace with `from invoke import task` for decorators, and use `from fabric import Connection` for connections.","cause":"Using old Fabric 1.x import pattern in Fabric v2+.","error":"ModuleNotFoundError: No module named 'fabric.decorators'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}