Search code examples
pythonfabric

Fabric ImportError: cannot import name 'isMappingType' with Python 2.7


I am trying to get Fab up and running locally. Why is Fab installing to /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5? The system Python version is 2.7.10, confirmed below:

Toms-MBP:~ tom$ which python
/usr/local/bin/python
Toms-MBP:~ tom$ python --version
Python 2.7.10
Toms-MBP:~ tom$ head -1 `which fab`
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Toms-MBP:~ tom$ fab
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/bin/fab", line 9, in <module>
    load_entry_point('Fabric==1.11.1', 'console_scripts', 'fab')()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/fabric/main.py", line 13, in <module>
    from operator import isMappingType
ImportError: cannot import name 'isMappingType'

Solution

  • Its look like you aren't using a virtualenv configured previously, so I think that the system just uses the normal path to python which means to /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 .

    This error is usual when we try use Fabric with python3.x because Fabric has not been update to this version of python which is really sad.