4

I'd like to use the Python 3 interpreter within collectd, but there's no (documented) option to set the path or the version of the interpreter, and it defaults to the Python 2 interpreter that's also installed on my system (at /usr/bin/python2.7).

My Python 3 interpreter is located at /usr/bin/python3 and /usr/bin/python is symlinked to it; running "env python" and "python" both give me the Python 3 interpreter.

The documentation (unclear and looks unfinished IMO) on collectd's Python plugin mentions Python 3 :

Encoding Name - The default encoding for Unicode objects you pass to collectd. If you omit this option it will default to ascii on Python 2 and utf-8 on Python 3. This is hardcoded in Python and will ignore everything else, including your locale.

But that doesn't tell how to actually use Python 3 with it and Google doesn't seem to know either.

1 Answers1

4

You might need to recompile collectd.

Take a look here:

https://github.com/collectd/collectd/blob/master/src/pyconfig.c

From what I can see (please correct me if I am wrong). The #include <Python.h> and #include "cpython.h" statically build the python version. So whatever version of Python that is currently in your LD Path will be used to build the module, and that version will be used to execute the plugin.

Joseph Kern
  • 9,809
  • 3
  • 31
  • 55
  • Looks like you're right; I'll try it and accept your answer once I have more time (for the time being I just backported my script to Python 2, faster than recompiling the whole thing). –  Nov 10 '14 at 17:16