24
votes

How to get a working Python Fabric installation on Windows?

2
It isn't designed for it, but it does work on it, as illustrated by my own answer below (which was the reason for this question -> so I could share my solution). Please upvote the question again, so people can find this help. - hopla
I'm pretty sure you don't need Cygwin for Fabric on Windows. This duplicates: stackoverflow.com/questions/1917193/…. You even get multiple hits when googling for 'python install fabric on windows' - Joao Figueiredo
Well then, give your instructions for an easy, WORKING Fabric install on Windows in the answers below. The question didn't state that solutions had to include Cygwin... - hopla
Since you edited your comment to point at the duplicates on Stackoverflow and Google: most of those instructions are hugely complicated, with code fixes left and right, are outdated and most of the time don't even work. - hopla
Btw: it doesn't duplicate the linked question, because that deals specifically with some readline error people get. Which in my solution below, isn't even an issue. - hopla

2 Answers

27
votes

fabric installs just fine on Windows, but you will need to either:

  1. have a compiler installed to build the pycrypto dependency during setup.If you don't have one already, install MinGW or you can use the free version of MSVC.
  2. install pre-built Windows binaries for pyCrypto here.

I install it in a virtualenv like so:

virtualenv fabenv
fabenv\Scripts\activate.bat
pip install fabric

Another Tip: When you have it up and running you can use pageant to load your ssh keys and avoiding using password-based authentication

7
votes

Solution using Cygwin:

  • Install Cygwin
  • Select packages: Python, Gcc, Wget and Openssh
  • In Cygwin run: python --version to verify your Python version
  • From http://pypi.python.org/pypi/setuptools download the .egg version of setuptools (NOT the Windows .exe), for your version of Python.
  • In Cygwin run: sh setuptools-*.egg to install the downloaded setuptools package
  • In Cygwin run: easy_install pip (I just like Pip, I think you could the next step with easy_install as well)
  • In Cygwin run: pip install fabric
  • And now comes the crucial part: if the above step fails with some "could not remap xxx.dll" error, on the install of the Python ssh package then:
  • Exit Cygwin
  • Start a cmd.exe an in it run: c:\cygwin_path\bin\ash.exe
  • In the ash shell run: /bin/rebaseall
  • In Cygwin retry: pip install fabric, it should succeed now :)