# ERROR! Unexpected Exception, this is probably a bug: cannot pickle '_io.TextIOWrapper' object

**URL:** https://discourse.roots.io/t/error-unexpected-exception-this-is-probably-a-bug-cannot-pickle-io-textiowrapper-object/23010
**Category:** trellis
**Tags:** ansible
**Created:** 2022-04-29T16:09:52Z
**Posts:** 7

## Post 1 by @broskees — 2022-04-29T16:09:52Z

Trying to run my ansible-playbook to deploy to Kinsta.

I’ve tried both [this solution](https://discourse.roots.io/t/issues-installing-ansible-on-mac-os/18175/2) to no avail and haven’t been able to find anything else that looks like it’ll work.

Here’s my `ansible --version` output:

```
/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
  "class": algorithms.Blowfish,
ansible 2.8.20
  config file = /Users/josephroberts/localdev/syracusehearingsolutions.com/trellis/ansible.cfg
  configured module search path = ['/Users/josephroberts/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible
  executable location = /Users/josephroberts/.pyenv/versions/3.10.3/bin/ansible
  python version = 3.10.3 (main, Apr 29 2022, 11:02:36) [Clang 12.0.5 (clang-1205.0.22.9)]
```

Here’s the output when running the playbook:

```
/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
  "class": algorithms.Blowfish,
[WARNING]: Skipping plugin (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible/plugins/filter/core.py) as it seems to be invalid: cannot import name 'environmentfilter' from
'jinja2.filters' (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/jinja2/filters.py)

[WARNING]: Skipping plugin (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible/plugins/filter/mathstuff.py) as it seems to be invalid: cannot import name 'environmentfilter' from
'jinja2.filters' (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/jinja2/filters.py)

PLAY [Ensure necessary variables are defined] ******************************************************************************************************************************************************************************
[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback./Users/josephroberts/localdev/syracusehearingsolutions.com/trellis/lib/trellis/plugins/callback/vars.CallbackModule object at 0x10c5da7d0>): 'AnsibleUnicode' object has no attribute
'get_groups'

skipping: no hosts matched

PLAY [Test Connection] *****************************************************************************************************************************************************************************************************
[WARNING]: You Ansible version is 2.8.20 but this version of Trellis has only been tested for compatability with Ansible 2.7.12 -> 2.8.4. It is advisable to check for Trellis updates or downgrade your Ansible version.

TASK [connection : Require manual definition of remote-user] ***************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: cannot pickle '_io.TextIOWrapper' object
```

Any thoughts on the matter?

---

## Post 2 by @broskees — 2022-05-04T15:56:41Z

Still dealing with this issue. Have been trying many combinations of python/ansible versions to no avail.

---

## Post 3 by @Mani_Prakash — 2022-05-04T15:59:38Z

for disabling error related to Cryptography, downgrade it to 36.0.2

pip3 uninstall -y cryptography  
pip3 install cryptography==36.0.2

for the 2nd issue, i am still struggling too.

---

## Post 4 by @giffengrabber — 2022-05-05T13:26:35Z

Regarding the first warning, `CryptographyDeprecationWarning: Blowfish has been deprecated`.

The issue there is with an “upstream” library called Paramiko.

I took a look at their GitHub page and [a fix is in the works](https://github.com/paramiko/paramiko/issues/2038). Brian Skinn stated that ”a fix will get pulled into a near-term future release”.

Alex Moir posted [a quite convenient workaround](https://github.com/paramiko/paramiko/issues/2038#issuecomment-1117345478), that eliminates the need to downgrade the cryptography package.

Hope this helps.

---

## Post 6 by @broskees — 2022-05-15T18:57:26Z

By using pyenv, I’ve finally been able to fix the issue with the following ansible version and python versions:

```
ansible 2.10.17
  config file = /Users/josephroberts/.ansible.cfg
  configured module search path = ['/Users/josephroberts/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible
  executable location = /Users/josephroberts/.pyenv/versions/3.10.3/bin/ansible
  python version = 3.10.3 (main, Apr 29 2022, 11:02:36) [Clang 12.0.5 (clang-1205.0.22.9)]
```

---

## Post 7 by @MWDelaney — 2022-05-16T14:04:15Z

Whenever you have environmental issues like this, try running the Trellis CLI command `trellis init` in the root of your project to install the correct versions of Trellis’s supporting software!
