How to install ansible to my python at Windows

Question:

When I tried to install ansible to my windows PC, stuck with following message.

    PS C:Userssungyong> pip install ansible
Collecting ansible
  Downloading ansible-2.3.2.0.tar.gz (4.3MB)
    100% |████████████████████████████████| 4.3MB 112kB/s
Requirement already satisfied: jinja2 in c:program filespython36libsite-packages (from ansible)
Requirement already satisfied: PyYAML in c:program filespython36libsite-packages (from ansible)
Collecting paramiko (from ansible)
  Downloading paramiko-2.2.1-py2.py3-none-any.whl (176kB)
    100% |████████████████████████████████| 184kB 286kB/s
Collecting pycrypto>=2.6 (from ansible)
  Downloading pycrypto-2.6.1.tar.gz (446kB)
    100% |████████████████████████████████| 450kB 187kB/s
Requirement already satisfied: setuptools in c:program filespython36libsite-packages (from ansible)
Requirement already satisfied: MarkupSafe>=0.23 in c:program filespython36libsite-packages (from jinja2->ansible)
Collecting pynacl>=1.0.1 (from paramiko->ansible)
  Downloading PyNaCl-1.1.2-cp36-cp36m-win_amd64.whl (131kB)
    100% |████████████████████████████████| 133kB 228kB/s
Requirement already satisfied: pyasn1>=0.1.7 in c:program filespython36libsite-packages (from paramiko->ansible)
Collecting cryptography>=1.1 (from paramiko->ansible)
  Downloading cryptography-2.0.3-cp36-cp36m-win_amd64.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 77kB/s
Collecting bcrypt>=3.1.3 (from paramiko->ansible)
  Downloading bcrypt-3.1.3-cp36-cp36m-win_amd64.whl
Collecting cffi>=1.4.1 (from pynacl>=1.0.1->paramiko->ansible)
  Downloading cffi-1.10.0-cp36-cp36m-win_amd64.whl (160kB)
    100% |████████████████████████████████| 163kB 122kB/s
Requirement already satisfied: six in c:program filespython36libsite-packages (from pynacl>=1.0.1->paramiko->ansible)
Requirement already satisfied: idna>=2.1 in c:program filespython36libsite-packages (from cryptography>=1.1->paramiko->ansible)
Collecting asn1crypto>=0.21.0 (from cryptography>=1.1->paramiko->ansible)
  Downloading asn1crypto-0.22.0-py2.py3-none-any.whl (97kB)
    100% |████████████████████████████████| 102kB 152kB/s
Collecting pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko->ansible)
  Downloading pycparser-2.18.tar.gz (245kB)
    100% |████████████████████████████████| 256kB 147kB/s
Installing collected packages: pycparser, cffi, pynacl, asn1crypto, cryptography, bcrypt, paramiko, pycrypto, ansible
  Running setup.py install for pycparser ... error
Exception:
Traceback (most recent call last):
  File "c:program filespython36libsite-packagespipcompat__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 81: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:program filespython36libsite-packagespipbasecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:program filespython36libsite-packagespipcommandsinstall.py", line 342, in run
    prefix=options.prefix_path,

File “c:program filespython36libsite-packagespipreqreq_set.py”, line 784, in install
**kwargs
File “c:program filespython36libsite-packagespipreqreq_install.py”, line 878, in install
spinner=spinner,
File “c:program filespython36libsite-packagespiputils__init__.py”, line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File “c:program filespython36libsite-packagespipcompat__init__.py”, line 75, in console_to_str
return s.decode(‘utf_8’)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xbe in position 81: invalid start byte

Is ansible available at windows environment? If yes, how can I fix this installation problem?

Asked By: sungyong

||

Answers:

Ansible is not supported on windows, but you can use a workaround(though not recommended), using Cygwin. Read about it here.

Answered By: Some1Else

use wsl. On Win10 and higher, just run

wsl --install

and choose the distro you want. Then you can install ansible using ‘wsl apt’, or ‘wsl sudo apt’.

From there you can run all the normal ansible commands. The only tricky thing is when you’re at the PS prompt. If you’re using wsl, you need to use Unix separators for full path like:

dir C:Temp

becomes

wsl ls /mnt/c/temp

But the convenience of running powershell and ansible from the same prompt is more than worth it.

Answered By: adamt8
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.