ERROR! Unexpected Exception, this is probably a bug: cannot import name '_psutil_linux'

2,616 views
Skip to first unread message

driCs

unread,
Oct 2, 2020, 5:49:32 AM10/2/20
to AWX Project
Hello,

I have created a virtualenv but when I run my Template I have this error

Below a part of my script to install some librairies into the virtualenv is :

.../venv/2.8.3/bin/pip install pip
.../venv/2.8.3/bin/pip install wheel
.../venv/2.8.3/bin/pip install psutil
.../venv/2.8.3/bin/pip install python-memcached
.../venv/2.8.3/bin/pip install infoblox-client
.../venv/2.8.3/in/pip install dnspython
.../venv/2.8.3/bin/pip install py3hpecw7
.../venv/2.8.3/bin/pip install pycurl
.../venv/2.8.3/bin/pip install "ansible == $1"
.../venv/2.8.3/bin/pip install ansible-tower-cli
.../venv/2.8.3/bin/pip install "boto3==1.14.14"
.../venv/2.8.3/bin/pip install "openstacksdk==0.46.0"


Identity added: /tmp/awx_208_bvp2hq8k/artifacts/208/ssh_key_data (/tmp/awx_208_bvp2hq8k/artifacts/208/ssh_key_data)
ansible-playbook 2.8.3
config file = /etc/ansible/ansible.cfg
configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /users/share/awx00/venv/2.8.3/lib/python3.8/site-packages/ansible
executable location = /users/share/awx00/venv/2.8.3/bin/ansible-playbook
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
Using /etc/ansible/ansible.cfg as config file
ERROR! Unexpected Exception, this is probably a bug: cannot import name '_psutil_linux'
to see the full traceback, use -vvv

Does anyone have an idea?

Note : psutil and python-memcached are installed as you can see with the "pip list" result below !


Package            Version
------------------ ---------
ansible            2.8.3
ansible-tower-cli  3.3.9
appdirs            1.4.4
bcrypt             3.2.0
boto3              1.14.14
botocore           1.17.63
certifi            2020.6.20
cffi               1.14.3
chardet            3.0.4
click              6.7
colorama           0.4.3
cryptography       3.1.1
debtcollector      2.2.0
decorator          4.4.2
dnspython          2.0.0
docutils           0.15.2
dogpile.cache      1.0.2
future             0.18.2
idna               2.10
infoblox-client    0.5.0
ipaddr             2.2.0
iso8601            0.1.13
Jinja2             2.11.2
jmespath           0.10.0
jsonpatch          1.26
jsonpointer        2.0
keystoneauth1      4.2.1
lxml               4.5.2
MarkupSafe         1.1.1
msgpack            1.0.0
munch              2.5.0
ncclient           0.6.9
netaddr            0.8.0
netifaces          0.10.9
openstacksdk       0.46.0
os-service-types   1.7.0
oslo.config        8.3.2
oslo.context       3.1.1
oslo.i18n          5.0.1
oslo.log           4.4.0
oslo.serialization 4.0.1
oslo.utils         4.6.0
packaging          20.4
paramiko           2.7.2
pbr                5.5.0
pip                20.0.2
pkg-resources      0.0.0
psutil             5.7.2
py3hpecw7          0.1.1
pycparser          2.20
pycurl             7.43.0.6
pyinotify          0.9.6
PyNaCl             1.4.0
pyparsing          2.4.7
python-dateutil    2.8.1
python-memcached   1.59
pytz               2020.1
PyYAML             5.3.1
requests           2.24.0
requestsexceptions 1.4.0
rfc3986            1.4.0
s3transfer         0.3.3
scp                0.13.2
setuptools         44.0.0
six                1.15.0
stevedore          3.2.2
textfsm            1.1.0
urllib3            1.25.10
wheel              0.35.1
wrapt              1.12.1

Thanks !! :)

Yannick Emminghaus

unread,
Oct 7, 2020, 3:31:55 AM10/7/20
to AWX Project
Hello,

I have also encountered this issue:

ansible-playbook 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/my-envs/pythonsdk-venv/lib/python3.8/site-packages/ansible
executable location = /opt/my-envs/pythonsdk-venv/bin/ansible-playbook
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
ERROR! Unexpected Exception, this is probably a bug: cannot import name '_psutil_linux'

Did you by any chance find a solution?

driCs

unread,
Oct 7, 2020, 3:55:10 AM10/7/20
to AWX Project
Hello,

I haven't really found a solution.
The workaround that I found (but it's really not good) is to create a virtualenv, then install the libraries "wheel", "psutil", "ansible" etc..

Then on AWX, execute a template which returns me the error message "cannot import name '_psutil_linux" then uninstall the "psutil" library from my virtualenv .
I then execute the same template and it works!

Note that if I create the virtualenv WITHOUT "psutil", I get the message "no module named psutil" ...!  unbelievable.....

Issue with my server (python?) ?

Do you have the same issue?

Yannick Emminghaus

unread,
Oct 7, 2020, 4:27:21 AM10/7/20
to AWX Project
Hey,

thanks for your reply.
I can confirm that uninstalling psutil I can execute the template in the virtualenv.
This is really weird.

Then the next module error appears telling me ansible vault would require the cryptography module, which also is installed.
Could be a python error, I am not sure.

I will experiment a bit and report back if I find anything helpful.

Yannick Emminghaus

unread,
Oct 7, 2020, 5:32:12 AM10/7/20
to AWX Project
Well I have noticed something weird.

In the AWX Log this is the output:

ansible-playbook 2.10.2
config file = /etc/ansible/ansible.cfg
configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/my-envs/pythonsdk-venv/lib/python3.8/site-packages/ansible
executable location = /opt/my-envs/pythonsdk-venv/bin/ansible-playbook
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]


But if I check /opt/my-envs/pythonsdk-venv/bin/ansible-playbook --version:

ansible-playbook 2.10.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/my-envs/pythonsdk-venv/lib/python3.8/site-packages/ansible
  executable location = /opt/my-envs/pythonsdk-venv/bin/ansible-playbook
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]

Inside the Docker-Containers I get:

ansible-playbook 2.9.13
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

Does AWX not use the ansible in the venv?
It seems to be using the Container Version.

driCs

unread,
Oct 8, 2020, 2:09:34 AM10/8/20
to AWX Project
Yes It's seems when I run my Template with the virtualenv, the python version is 3.6.8 (python version inside container) and not 3.8.5 (version inside my custom virtualenv)

I would like to have the advice of Ryan Petrello, the best in AWX :-) ahah
Reply all
Reply to author
Forward
0 new messages