# Using ayncio and mtrpacket with Python.d.plugin by switching to Python3

**URL:** <https://community.netdata.cloud/t/using-ayncio-and-mtrpacket-with-python-d-plugin-by-switching-to-python3/868>\
**Category:** Help\
**Tags:** agent-collector, agent\
**Created:** [February 3, 2021, 1:50pm UTC](https://community.netdata.cloud/t/using-ayncio-and-mtrpacket-with-python-d-plugin-by-switching-to-python3/868 "2021-02-03T13:50:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LydiaKN](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/lydiakn/32/441_2.png) [@LydiaKN](https://community.netdata.cloud/u/LydiaKN)\
**Post date:** [February 3, 2021, 1:50pm UTC](https://community.netdata.cloud/t/using-ayncio-and-mtrpacket-with-python-d-plugin-by-switching-to-python3/868/1 "2021-02-03T13:50:29Z")

</div>

I am tryinng to write a data collection module in Python and I need to use these libraries, asyncio and mtrpacket, that are written for Python3. However, python.d, uses pythonv2 for debugging and I have a SyntaxError while running the code. The error is:

[mtr] error on loading source : SyntaxError(‘invalid syntax’, (‘/usr/libexec/netdata/python.d/mtr.chart.py’, 16, 9, ‘async def trace(host):\n’)), skipping it

Is there any way to switch to Python3 in order to use these libraries?

Netdata is installed on Ubuntu 18.04 laptop.

Any help would be extremely useful.  
Thanks!

---

<div class="post-metadata">

**Author:** ![OdysLam](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/odyslam/32/98_2.png) [@OdysLam](https://community.netdata.cloud/u/OdysLam)\
**Post date:** [February 3, 2021, 2:06pm UTC](https://community.netdata.cloud/t/using-ayncio-and-mtrpacket-with-python-d-plugin-by-switching-to-python3/868/2 "2021-02-03T14:06:15Z")

</div>

Hey @LydiaKN,

Welcome to our community!

As per the following GitHub issue, it is possible to use `python3` for both the debug and the normal use of Netdata.

To enable python3 for Netdata in general, please go to `netdata.conf` and make the following additions:

```nohighlight
[plugin:python.d]
	# update every = 1
	command options = -ppython3

```

For the debug, you will need to pass the python version as an argument: `./python.d.plugin -ppython3 <name_of_plugin> debug trace`

If it doesn’t work out, please tell me so and we will make it work!

> <https://github.com/netdata/netdata/issues/8726>
>
> \<!---
> When asking a new question please:
> \- Verify first that your question was…n't asked before on GitHub. 
> HINT: Use label "question" when searching for such issues.
> \- Briefly explain what is the problem you are having
> \- Try to provide as much information about your environment (OS distribution,
> running in container, etc.) as possible to allow us reproduce this bug faster.
> \- Write which component is affected. We group our components the same way our
> code is structured so basically:
> component name = dir in top level directory of repository
> \- Provide a clear and concise description of what you expected to happen.
> \--\>
> 
> \##### Question summary
> I know python plugins should be written in a way that can be executed by both python2 and python3, but every time netdata runs python2:
> \`\`\` bash
> 2020-04-15 20:33:10: python.d INFO: plugin\[main\] : using python v2
> 2020-04-15 20:33:10: python.d DEBUG: plugin\[main\] : looking for 'python.d.conf' in \['/opt/netdata/etc/netdata', '/opt/netdata/usr/lib/netdata/conf.d'\]
> 2020-04-15 20:33:10: python.d DEBUG: plugin\[main\] : loading '/opt/netdata/etc/netdata/python.d.conf'
> 2020-04-15 20:33:10: python.d DEBUG: plugin\[main\] : '/opt/netdata/etc/netdata/python.d.conf' is loaded
> \`\`\`
> Is it possible to make netdata run the python plugins using python3?
> 
> \##### Component Name
> plugins

We would love to hear about the collector you have created! If you want to share more about your use-case, why you created the collector, and how you use it, we would love to continue the discussion in #agent-development. If you need any help in further developing your collector, just create a new topic there!

Best,  
Odysseas

---

<div class="post-metadata">

**Author:** ![LydiaKN](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/lydiakn/32/441_2.png) [@LydiaKN](https://community.netdata.cloud/u/LydiaKN)\
**Post date:** [February 3, 2021, 8:32pm UTC](https://community.netdata.cloud/t/using-ayncio-and-mtrpacket-with-python-d-plugin-by-switching-to-python3/868/3 "2021-02-03T20:32:19Z")

</div>

Thank you very much for your quick and helpful reply.  
I am trying to create a chart, which displays every RTT(round trip time) of packets, received from each successive host in a network path(route).

---

<div class="post-metadata">

**Author:** ![OdysLam](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/odyslam/32/98_2.png) [@OdysLam](https://community.netdata.cloud/u/OdysLam)\
**Post date:** [February 5, 2021, 6:18pm UTC](https://community.netdata.cloud/t/using-ayncio-and-mtrpacket-with-python-d-plugin-by-switching-to-python3/868/4 "2021-02-05T18:18:54Z")

</div>

@ilyam8 perhaps you will find this interesting ✌
