Python 3 support for fabric
Current advice
It seems there is already official support for Python 3.4+ in Fabric v2+ and I guess it should be preferred although there may be some incompatible changes. So in an ideal world, nobody should have this problem anymore :)
pip3 install -U "fabric>2.0"
Maintained old API in Python 3
Because some people were happy with the old API of the Fabric, there is a maintained fork supporting Python 3 called fab-classic. See also discussion in the Github issue Recreating the Fabric 1 API in Fabric 2?
The previous advice
There is Python3 port of Fabric named Fabric3 which supports Python 2.7 and 3.4+ (dropped support for Python <2.7). I use it some time as a replacement and it works for me without any issues.
pip3 install fabric3
Current Answer which has already been done by @miso.belica
pip install -U "fabric>2.0.0"
OLD Answer (as of 2013)
From the docs:
Please note that all documentation is currently written with Python 2.5 users in mind, but with an eye for eventual Python 3.x compatibility
Or to be more specific:
eventual Python 3.x compatibility
It looks like Python3 support for fabric is a little sticky and depends upon another open source library, paramiko
being compatible with python3. As of now, the master version supports python 3.
It might be worth messing around with and then building your fabric instance on top of that instead of getting it from pip.
You could also create a separate python2.7 virtualenv just for fabric:
sudo virtualenv --no-site-packages -p /usr/bin/python fabric-env
source /var/www/APPNAME/fabric-env/bin/activate
sudo /var/www/APPNAME/fabric-env/bin/pip install fabric
deactivate
Then:
/var/www/APPNAME/fabric-env/bin/fab -f /var/www/APPNAME/fabfile.py FAB_COMMAND
It seems that Fabric is going through a rewrite and that Fabric 2.0 will be python 3.x compatible. At least this is what I read between the line of the roadmap below. However, I cannot find the Fabric 2.0 repository or branch, so, hard to fully confirm.
http://www.fabfile.org/roadmap.html
For those looking for a supported version of Fabric 1.x, there's a fork which is maintained: https://github.com/ploxiln/fab-classic
I recommend using it in case you don't want to rewrite all the existing code. And it works with Python 3.7.
We've switched from fabric3==1.14.post1
to fab-classic==1.15.2
without any problems.