0

After changing the default python path ansible cannot run or load any python library

{  
   "changed":false,
   "failed":true,
   "module_stderr":"Shared connection to x.x.x.x closed.\r\n",
   "module_stdout":"Traceback (most recent call last):\r\n  File \"/home/user/.ansible/tmp/ansible-tmp-1510222878.61-64380131096787/setup.py\", line 123, in <module>\r\n    f.write(z.read('ansible_module_setup.py'))\r\n  File \"/home/user/python/lib/p`enter code here`ython2.7/zipfile.py\", line 935, in read\r\n    return self.open(name, \"r\", pwd).read()\r\n  File \"/home/user/python/lib/python2.7/zipfile.py\", line 1010, in open\r\n    close_fileobj=should_close)\r\n  File \"/home/user/python/lib/python2.7/zipfile.py\", line 526, in __init__\r\n    self._decompressor = zlib.decompressobj(-15)\r\nAttributeError: 'NoneType' object has no attribute 'decompressobj'\r\n",
   "msg":"MODULE FAILURE",
   "rc":0
}

i've also tried to run ansible -m ping i get pretty much the same result

{  
   "changed":false,
   "failed":true,
   "module_stderr":"Shared connection to x.x.x.x closed.\r\n",
   "module_stdout":"Traceback (most recent call last):\r\n  File \"/home/user/.ansible/tmp/ansible-tmp-1510223942.9-58678212493208/ping.py\", line 123, in <module>\r\n    f.write(z.read('ansible_module_ping.p 
y'))\r\n  File \"/home/user/python/lib/python2.7/zipfile.py\", line 935, in read\r\n    return self.open(name, \"r\", pwd).read()\r\n  File \"/home/user/python/lib/python2.7/zipfile.py\", line 1010, in open\r\
n    close_fileobj=should_close)\r\n  File \"/home/user/python/lib/python2.7/zipfile.py\", line 526, in __init__\r\n    self._decompressor = zlib.decompressobj(-15)\r\nAttributeError: 'NoneType' object has no a
ttribute 'decompressobj'\r\n",
   "msg":"MODULE FAILURE",
   "rc":0
}

ansible 2.3.2.0

python 2.7.11

any help would be very much appreciated !

  • Why did you expect it to work? Why did you change it to begin with? – Satō Katsura Nov 9 '17 at 12:53
  • well changing the default python interpreted is common + there are two version of python installed on the machine, some of ansible modules (maven_artifact) expects some dependencies ( lxml ) and those dependencies work with at least python v2.7 – hkhelil Nov 9 '17 at 12:57
  • You just found out why it's a bad idea to have two version of Python installed. – Satō Katsura Nov 9 '17 at 13:00
  • well i figured that would create a problem but is there an alternative to work with two versions installed ? – hkhelil Nov 9 '17 at 13:05
  • Depends on versions. You can handle Python 2 vs. Python 3 with virtualenv, pyenv, or equivalent. You still need to understand what you're doing, and not fight the system's package manager. – Satō Katsura Nov 9 '17 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.