2

I installed Ansible on windows server 2012 via python 3.7 (follow by instructions of this post: https://stackoverflow.com/a/52614973/7098543).

But, I got error: No module named ansible.main. How can I solve it?

I know that Ansible does not support to install control machine on Windows. But, I have to use Windows server 2012.

After I installed Ansible (version: 2.7.10) via python 3.7, I try to run:

python -m ansible --version

I got error: No module named ansible.main; 'ansible' is a package and cannot be directly executed.

Any workaround? Please help.

4
  • what is the value of python --version ? Commented Apr 24, 2019 at 9:43
  • hi @error404 python version is: 3.7.3 Commented Apr 24, 2019 at 10:16
  • thanks just wanted to make sure there is no other python version. Also python is a package so can you try. python >>> import ansible Commented Apr 24, 2019 at 12:31
  • Thanks! Yup, I ran that command. But, still got error. Commented Apr 24, 2019 at 14:40

1 Answer 1

1

Actually, I have no idea or workaround to solve this issues. But, I found other solution to install Ansible with Cygwin.

    1. Open up a Cygwin Terminal
    2. alias cyg-get="/path/to/cygwin/setup/package/setup-x86_64.exe -q -P"
    3. cyg-get cygwin32-gcc-g++,gcc-core,gcc-g++,git,libffi-devel,nano,openssl,openssl-devel,python-crypto,python3,python3-devel,python3-openssl,python3-pip,python3-setuptools,python3-devel,tree,wget,zip,make,curl,git python-jinja2,python-six,python-yaml, cryptography
    4. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    5. python3 get-pip.py
    6. pip --version
    7. git clone --depth 1 git://github.com/ansible/ansible
    8. cd ansible
    9. python3 setup.py install

Hope this post help someone! Refrence link:

  1. Cygwin - How to install ansible?
  2. How to overcome - pip install ansible on windows failing with filename or extension too long on windows
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your sharing, the same issue kept bugging me for awhile.
Hope helped for u!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.