# Installation of ansible in WSL2 fails

**URL:** <https://forum.ansible.com/t/installation-of-ansible-in-wsl2-fails/3240>\
**Category:** Get Help\
**Tags:** install, ansible\
**Created:** [January 10, 2024, 11:29am UTC](https://forum.ansible.com/t/installation-of-ansible-in-wsl2-fails/3240 "2024-01-10T11:29:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norbert](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@Norbert](https://forum.ansible.com/u/Norbert)\
**Post date:** [January 10, 2024, 11:29am UTC](https://forum.ansible.com/t/installation-of-ansible-in-wsl2-fails/3240/1 "2024-01-10T11:29:57Z")

</div>

I try to install ansible in a WSL2 instance (Debian) and got the following issues:  
According to [https://docs.ansible.com/ansible/latest/installation\_guide/intro\_installation.html#id18](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#id18) I did

```auto
$ python3 -m pip install --user ansible

```

but this gave the

> **error: externally-managed-environment**
>
> ```auto
> 
> × This environment is externally managed
> ╰─> To install Python packages system-wide, try apt install
> python3-xyz, where xyz is the package you are trying to
> install.
>     
> If you wish to install a non-Debian-packaged Python package,
> create a virtual environment using python3 -m venv path/to/venv.
> Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
> sure you have python3-full installed.
>     
> If you wish to install a non-Debian packaged Python application,
> it may be easiest to use pipx install xyz, which will manage a
> virtual environment for you. Make sure you have pipx installed.
>     
> See /usr/share/doc/python3.11/README.venv for more information.
> 
> note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
> 
> ```

I installed pipx and tried

```auto
pipx install --include-deps ansible
Fatal error from pip prevented installation. Full pip output in file:
    /home/norbert/.local/pipx/logs/cmd_2024-01-10_12.26.55_pip_errors.log

pip seemed to fail to build package:
    pycparser

Some possibly relevant errors from pip install:
    ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2546)
    pip._vendor.urllib3.exceptions.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2546)

Error installing ansible.

```

> **The error log showed**
>
> ```auto
> PIP STDOUT
> ----------
> Collecting ansible
> Using cached ansible-9.1.0-py3-none-any.whl.metadata (7.9 kB)
> Collecting ansible-core~=2.16.1 (from ansible)
> Using cached ansible_core-2.16.2-py3-none-any.whl.metadata (6.9 kB)
> Collecting jinja2>=3.0.0 (from ansible-core~=2.16.1->ansible)
> Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
> Collecting PyYAML>=5.1 (from ansible-core~=2.16.1->ansible)
> Using cached PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
> Collecting cryptography (from ansible-core~=2.16.1->ansible)
> Using cached cryptography-41.0.7-cp37-abi3-manylinux_2_28_x86_64.whl.metadata (5.2 kB)
> Collecting packaging (from ansible-core~=2.16.1->ansible)
> Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB)
> Collecting resolvelib<1.1.0,>=0.5.3 (from ansible-core~=2.16.1->ansible)
> Using cached resolvelib-1.0.1-py2.py3-none-any.whl (17 kB)
> Collecting MarkupSafe>=2.0 (from jinja2>=3.0.0->ansible-core~=2.16.1->ansible)
> Using cached MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
> Collecting cffi>=1.12 (from cryptography->ansible-core~=2.16.1->ansible)
> Using cached cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB)
> Collecting pycparser (from cffi>=1.12->cryptography->ansible-core~=2.16.1->ansible)
> Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
> Downloading ansible-9.1.0-py3-none-any.whl (48.1 MB)
> ━━━━━━━━━━━━━━━━ 19.8/48.1 MB 10.5 MB/s eta 0:00:03
> 
> PIP STDERR
> ----------
> ERROR: Exception:
> Traceback (most recent call last):
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
> yield
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/urllib3/response.py", line 561, in read
> data = self._fp_read(amt) if not fp_closed else b""
> ^^^^^^^^^^^^^^^^^^
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
> return self._fp.read(amt) if amt is not None else self._fp.read()
> ^^^^^^^^^^^^^^^^^^
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 98, in read
> data: bytes = self.__fp.read(amt)
> ^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/http/client.py", line 465, in read
> s = self.fp.read(amt)
> ^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/socket.py", line 706, in readinto
> return self._sock.recv_into(b)
> ^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/ssl.py", line 1278, in recv_into
> return self.read(nbytes, buffer)
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/ssl.py", line 1134, in read
> return self._sslobj.read(len, buffer)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2546)
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
> status = run_func(*args)
> ^^^^^^^^^^^^^^^
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
> return func(self, options, args)
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 377, in run
> requirement_set = resolver.resolve(
> ^^^^^^^^^^^^^^^^^
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 179, in resolve
> self.factory.preparer.prepare_linked_requirements_more(reqs)
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 552, in prepare_linked_requirements_more
> self._complete_partial_requirements(
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 467, in _complete_partial_requirements
> for link, (filepath, _) in batch_download:
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/network/download.py", line 183, in __call__
> for chunk in chunks:
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar
> for chunk in iterable:
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks
> for chunk in response.raw.stream(
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream
> data = self.read(amt=amt, decode_content=decode_content)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/urllib3/response.py", line 560, in read
> with self._error_catcher():
> File "/usr/lib/python3.11/contextlib.py", line 155, in __exit__
> self.gen.throw(typ, value, traceback)
> File "/home/norbert/.local/pipx/shared/lib/python3.11/site-packages/pip/_vendor/urllib3/response.py", line 449, in _error_catcher
> raise SSLError(e)
> pip._vendor.urllib3.exceptions.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2546)
> 
> ```

And now I am stuck.

Any Ideas how to proceed ?

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![Norbert](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@Norbert](https://forum.ansible.com/u/Norbert)\
**Post date:** [January 10, 2024, 11:47am UTC](https://forum.ansible.com/t/installation-of-ansible-in-wsl2-fails/3240/2 "2024-01-10T11:47:16Z")

</div>

According to `/usr/share/doc/python3.11/README.venv` i hacked the system with

```auto
sudo dpkg-divert --rename --add /usr/lib/$(py3versions -d)/EXTERNALLY-MANAGED

Adding 'local diversion of /usr/lib/python3.11/EXTERNALLY-MANAGED to /usr/lib/python3.11/EXTERNALLY-MANAGED.distrib'

```

But the

> **problem persisted**
>
> ```auto
> pip install --user ansible
> Collecting ansible
> Downloading ansible-9.1.0-py3-none-any.whl (48.1 MB)
> ━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.1/48.1 MB 5.2 MB/s eta 0:00:09
> ERROR: Exception:
> Traceback (most recent call last):
> File "/usr/lib/python3/dist-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
> yield
> File "/usr/lib/python3/dist-packages/pip/_vendor/urllib3/response.py", line 561, in read
> data = self._fp_read(amt) if not fp_closed else b""
> ^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
> return self._fp.read(amt) if amt is not None else self._fp.read()
> ^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 90, in read
> data = self.__fp.read(amt)
> ^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/http/client.py", line 465, in read
> s = self.fp.read(amt)
> ^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/socket.py", line 706, in readinto
> return self._sock.recv_into(b)
> ^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/ssl.py", line 1278, in recv_into
> return self.read(nbytes, buffer)
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.11/ssl.py", line 1134, in read
> return self._sslobj.read(len, buffer)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2546)
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
> File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
> status = run_func(*args)
> ^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
> return func(self, options, args)
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 419, in run
> requirement_set = resolver.resolve(
> ^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
> result = self._result = resolver.resolve(
> ^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
> state = resolution.resolve(requirements, max_rounds=max_rounds)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
> self._add_to_criteria(self.state.criteria, r, parent=None)
> File "/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
> if not criterion.candidates:
> File "/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
> return bool(self._sequence)
> ^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
> return any(self)
> ^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
> return (c for c in iterator if id(c) not in self._incompatible_ids)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
> candidate = func()
> ^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
> self._link_candidate_cache[link] = LinkCandidate(
> ^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 297, in __init__
> super(). __init__ (
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
> self.dist = self._prepare()
> ^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
> dist = self._prepare_distribution()
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
> return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
> return self._prepare_linked_requirement(req, parallel_builds)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 536, in _prepare_linked_requirement
> local_file = unpack_url(
> ^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 166, in unpack_url
> file = get_http_url(
> ^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 107, in get_http_url
> from_path, content_type = download(link, temp_dir.path)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_internal/network/download.py", line 147, in __call__
> for chunk in chunks:
> File "/usr/lib/python3/dist-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar
> for chunk in iterable:
> File "/usr/lib/python3/dist-packages/pip/_internal/network/utils.py", line 63, in response_chunks
> for chunk in response.raw.stream(
> File "/usr/lib/python3/dist-packages/pip/_vendor/urllib3/response.py", line 622, in stream
> data = self.read(amt=amt, decode_content=decode_content)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3/dist-packages/pip/_vendor/urllib3/response.py", line 560, in read
> with self._error_catcher():
> File "/usr/lib/python3.11/contextlib.py", line 155, in __exit__
> self.gen.throw(typ, value, traceback)
> File "/usr/lib/python3/dist-packages/pip/_vendor/urllib3/response.py", line 449, in _error_catcher
> raise SSLError(e)
> pip._vendor.urllib3.exceptions.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2546)
> 
> ```

[SSL: DECRYPTION\_FAILED\_OR\_BAD\_RECORD\_MAC]

---

<div class="post-metadata">

**Author:** ![Norbert](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@Norbert](https://forum.ansible.com/u/Norbert)\
**Post date:** [January 10, 2024, 12:06pm UTC](https://forum.ansible.com/t/installation-of-ansible-in-wsl2-fails/3240/3 "2024-01-10T12:06:42Z")

</div>

I solved it with a direct download of ansible from pypi , the parameter `--retries 50`and several tries.

That seems to have been a problem with the network.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 9, 2024, 12:06pm UTC](https://forum.ansible.com/t/installation-of-ansible-in-wsl2-fails/3240/4 "2024-02-09T12:06:49Z")

</div>

Closed on February 9, 2024, 12:06pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
