I am trying to import fabric.api and having issues. I installed fabric using pip and it works fin when I run import fabric in the interpreter.

But when I do from fabric.api import * it spews out an error saying "No module named api". I am using Python 2.7. What am I missing here?

Python 2.7.10 (default, Oct  6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'version' is not defined
>>> import fabric
>>> import fabric.api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named api
>>> from "fabric.api" import *
  File "<stdin>", line 1
    from "fabric.api" import *

Fabric has made some major API changes from v1 to v2; to see the changes, visit Upgrading from Fabric 1.x: API organization. In particular, fabric.api is removed and everything is imported directly from the top-level package. This means that your scripts won't work with the current Fabric==2.0.1 version; you have two possibilities: rewrite your code to be compliant with v2, or install the latest v1 version:

$ pip install "fabric<2"

fabric.api is part of version


you installed


please check versions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.