fabric.api only exists in fabric 1.x, if you want to follow tutorials for that older version, you should install Fabric==1.14.0
If you'd like to use fabric 2.x, the docs on the site are updated (with an upgrade guide link at the bottom): http://fabfile.org/ On Sat, May 19, 2018 at 9:01 AM Kaushal Shriyan <kaushalshri...@gmail.com> wrote: > Hi, > > I am running the below Fabric version and when i execute the below fabric > python code i > > $fab -V > Fabric 2.0.1 > Paramiko 2.4.1 > Invoke 1.0.0 > $ > > > #!/usr/bin/env python >> from fabric.api import * >> # Set the username >> env.user = "root" >> # Set the password [NOT RECOMMENDED] >> env.password = "Apigee123!" >> >> out_log = open("output.txt", "w") >> with open("hosts.txt") as host_file: >> host_list = [x.strip() for x in host_file.readlines()] >> @hosts(host_list) >> def rpm(): >> with settings(warn_only=True): >> version = run("rpm -qa | grep libdb4") >> out_log.write("%s: %s" % (env.host, version)) > > > > $fab rpm > > Traceback (most recent call last): >> File "/usr/local/bin/fab", line 11, in <module> >> load_entry_point('fabric==2.0.1', 'console_scripts', 'fab')() >> File >> "/usr/local/Cellar/fabric/2.0.1/libexec/lib/python2.7/site-packages/invoke/program.py", >> line 321, in run >> self.parse_collection() >> File >> "/usr/local/Cellar/fabric/2.0.1/libexec/lib/python2.7/site-packages/invoke/program.py", >> line 399, in parse_collection >> self.load_collection() >> File >> "/usr/local/Cellar/fabric/2.0.1/libexec/lib/python2.7/site-packages/fabric/main.py", >> line 74, in load_collection >> super(Fab, self).load_collection() >> File >> "/usr/local/Cellar/fabric/2.0.1/libexec/lib/python2.7/site-packages/invoke/program.py", >> line 588, in load_collection >> module, parent = loader.load(coll_name) >> File >> "/usr/local/Cellar/fabric/2.0.1/libexec/lib/python2.7/site-packages/invoke/loader.py", >> line 75, in load >> module = imp.load_module(name, fd, path, desc) >> File "/Users/kaushalshriyan/singaporetraining/fabfile.py", line 2, in >> <module> >> from fabric.api import * >> ImportError: No module named api > > > Any help will be highly appreciable. Thanks in Advance. > > Best Regards, > > Kaushal > _______________________________________________ > Fab-user mailing list > Fab-user@nongnu.org > https://lists.nongnu.org/mailman/listinfo/fab-user >
_______________________________________________ Fab-user mailing list Fab-user@nongnu.org https://lists.nongnu.org/mailman/listinfo/fab-user