Consul can't find python module

659 views
Skip to first unread message

SurferL

unread,
Apr 10, 2018, 9:43:11 AM4/10/18
to Consul
Consul --version: v1.0.6

So on OSX, I've installed python2 with brew (Python 2.7.14)

I've also installed the psutil library with pip:

$ sudo pip install psutil

Requirement already satisfied: psutil in /usr/local/lib/python2.7/site-packages



I have a check which looks something like:


               {

"id": "cpuUsage",

"name": "CPU Usage",

"args": ["python", "/Users/consul/scripts/cpu_usage.py"],

"interval": "15s",

"timeout": "2s",

"status": "passing"

},



However, I'm getting an error with the following:


OUTPUT
Traceback (most recent call last):
  File "/Users/consul/scripts/cpu_usage.py", line 1, in <module>
    import psutil
ImportError: No module named psutil


But running the script manually works as intended on the machine.


It seems that the consul agent isn't able to access the python library which I installed via pip...?


Can anyone suggest a way to fix this?


Thanks!







Brian Lalor

unread,
Apr 10, 2018, 10:26:41 AM4/10/18
to consu...@googlegroups.com
The python consul is invoking is being resolved from the PATH env var used by consul when it’s started.  That’s apparently not the same PATH as your shell is set up to use.  Try replacing the “python” in the check’s “args” with the python actually used by your shell (“which python” to get you started).

-- 
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/consul/issues
Community chat: https://gitter.im/hashicorp-consul/Lobby
--- 
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/5dfe5ca6-e086-403a-a621-dd57d3e20e46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

— 
Brian Lalor

SurferL

unread,
Apr 10, 2018, 10:33:32 AM4/10/18
to Consul
Yup this is it - I had to change the `python` arg to `/usr/local/bin/python`

Thanks!
Reply all
Reply to author
Forward
0 new messages