pythonfabricimporterror

Python import error :No module named Fabric.api?


I am getting the following error:

Traceback (most recent call last):
  File "drayd.py", line 2, in <module>
    from fabric.api import *
**ImportError: No module named fabric.api**

I am running my program using:

python drayd.py

These are my imports:

import os,pprint
from fabric.api import *
import time
import argparse
import ConfigParser

I don't have a file named fabric as other answers suggested. I installed fabric using pip but it still doesn't work, any suggestions? I am using the OSX Terminal.

NOTE: I realized the fabric I installed is not linked to python installation ie it does not recognize that fabric is installed by pip. I am using the python version 2.7 default by osx. How do I link fabric installation to python?


Solution

  • The answer to my question is right here :

    PIP install and Python path

    I had to add the location of my packages( which were installing not in the sys.path) so I had to add them manually Use pip show to find location of the packages and add them to .bash_profile as @Javier Buzzi said I will take the advice and also run my python code from virtualenv.