# Unexpected behaviour when using python influxdb client on Raspberry

**URL:** <https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460>\
**Category:** Telegraf\
**Tags:** influxdb\
**Created:** [June 7, 2018, 2:41pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460 "2018-06-07T14:41:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![frankhochmuth](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@frankhochmuth](https://community.influxdata.com/u/frankhochmuth)\
**Post date:** [June 7, 2018, 2:41pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/1 "2018-06-07T14:41:21Z")

</div>

Hi, after having successfully run some python code uploading JSON formatted data to an InfluxDB on a VPS instance. The code runs fine on a Ubuntu 16.04 client and also on a Windows client, however the very same code does not provide the same results on a Raspberry Pi 3. Rather than getting a confirmation that the data upload has been successful I am receiving messages like http error 404 and number not JSON seriesable.

I am using Python 3.6 on the Ubuntu and the Windows machines, and 3.4.2 on the Raspberry. Other than that I am not sure why there is a different behaviour. I am beginning to believe that for some reason the python-influxdb package I am using on teh raspberry is outdated, however, I am not sure why that would be. I tried installing both with pip as well as with apt-get, the errors are similar albeit not the same.

Could someone point me in the right direction please? Thanks.  
Frank

---

<div class="post-metadata">

**Author:** ![noahcrowley](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/noahcrowley/32/818_2.png) [@noahcrowley](https://community.influxdata.com/u/noahcrowley)\
**Post date:** [June 7, 2018, 2:55pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/2 "2018-06-07T14:55:54Z")

</div>

Can you post your code and the errors your seeing, as well as the versions of influxdb-python you have installed?

---

<div class="post-metadata">

**Author:** ![frankhochmuth](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@frankhochmuth](https://community.influxdata.com/u/frankhochmuth)\
**Post date:** [June 7, 2018, 7:07pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/3 "2018-06-07T19:07:00Z")

</div>

Hi Noah, here is the code. Some data and the errors are below. But your main question regarding the influxdb versions seems to be most interesting… On Ubuntu its version 5.0.0, and on Raspbian its 0.1.12. So I guess the next question is how to get the latest version for Raspbian installed? I tried both with pip and apt-get (after running update). Can you let me know?

Update:  
just checked and it says that python-influxdb is the latest version (no idea which one - how do I find out?)  
however, I also installed python3-influxdb , which is version 0.1.12-1

Thanks for your help.

```
    def publish_data(self):
        client = InfluxDBClient(INFLUXDB_HOST, '8086', '', '', INFLUXDB_NAME)
        response = client.write_points(self.data, time_precision='s')

```

data (excerpt):  
…‘tags’: {‘Station’: ‘CA48’}, ‘measurement’: ‘Enphase\_Watt’}, {‘fields’: {‘value’: 150}, ‘time’: 1528395300, ‘tags’: {‘Station’: ‘CA48’}, ‘measurement’: ‘Enphase\_Watt’}, {‘fields’: {‘value’: 125}, ‘time’: 1528395600, ‘tags’: {‘Station’: ‘CA48’}, ‘measurement’: ‘Enphase\_Watt’}, {‘fields’: {‘value’: 120}, ‘time’: 1528395900, ‘tags’: {‘Station’: ‘CA48’}, ‘measurement’: ‘Enphase\_Watt’}, {‘fields’: {‘value’: 101}, ‘time’: 1528396200, ‘tags’: {‘Station’: ‘CA48’}, ‘measurement’: ‘Enphase\_Watt’}]  
Exception in thread Read\_Enphase:  
Traceback (most recent call last):  
File “/usr/lib/python3.4/threading.py”, line 920, in \_bootstrap\_inner  
self.run()  
File “/home/pi/Documents/Pumpberry/Pumpberry\_main\_v33 test.py”, line 86, in run  
self.publish\_data()  
File “/home/pi/Documents/Pumpberry/Pumpberry\_main\_v33 test.py”, line 62, in publish\_data  
response = client.write\_points(self.data, time\_precision=‘s’)  
File “/usr/local/lib/python3.4/dist-packages/influxdb/client.py”, line 468, in write\_points  
tags=tags, protocol=protocol)  
File “/usr/local/lib/python3.4/dist-packages/influxdb/client.py”, line 532, in \_write\_points  
protocol=protocol  
File “/usr/local/lib/python3.4/dist-packages/influxdb/client.py”, line 300, in write  
data = make\_lines(data, precision).encode(‘utf-8’)  
File “/usr/local/lib/python3.4/dist-packages/influxdb/line\_protocol.py”, line 159, in make\_lines  
\_convert\_timestamp(point[‘time’], precision))))  
File “/usr/local/lib/python3.4/dist-packages/influxdb/line\_protocol.py”, line 44, in \_convert\_timestamp  
raise ValueError(timestamp)  
ValueError: 1528351500

---

<div class="post-metadata">

**Author:** ![noahcrowley](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/noahcrowley/32/818_2.png) [@noahcrowley](https://community.influxdata.com/u/noahcrowley)\
**Post date:** [June 8, 2018, 8:53pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/4 "2018-06-08T20:53:51Z")

</div>

Are you using the system python? What about pyenv?

To see what version of the library you have installed, you can use `pip show influxdb`. I suggest running pip using the `-m` argument to the python command to ensure you know which version of python was the target:

```bash
pi@raspberrypi:~ $ python3 -m pip show influxdb
Name: influxdb
Version: 5.0.0
Summary: InfluxDB client
Home-page: https://github.com/influxdb/influxdb-python
[...]

```

You can upgrade to the latest version of the library using `pip install --upgrade`:

```bash
pi@raspberrypi:~ $ python3 -m pip install --upgrade influxdb

```

---

<div class="post-metadata">

**Author:** ![frankhochmuth](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@frankhochmuth](https://community.influxdata.com/u/frankhochmuth)\
**Post date:** [June 9, 2018, 8:56am UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/5 "2018-06-09T08:56:01Z")

</div>

Thanks. I now managed to uninstall the old pip and the old influxdb-python, and install the 5.0.0 version for Python3, in spite of the “owned by OS” restrictions. I checked from outside and inside Python3 the version (using print (influxdb. **version** ), and it seems all fine now.

However, the program still produces the same, unexpected results, like printing “True” on the screen in one class instance and printing a Unix time stamp in the other.

Sat Jun 9 10:52:47 2018: 1 0.01 Running process: Read\_PVsyst  
Sat Jun 9 10:52:47 2018: 1 0.01 Publishing data…  
True  
Sat Jun 9 10:52:47 2018: 1 0.01 Response:True  
Sat Jun 9 10:52:47 2018: 1 0.18 Running process: Read\_Enphase  
Sat Jun 9 10:52:47 2018: 1 0.18 response:200  
Sat Jun 9 10:52:47 2018: 1 0.18 Publishing data…  
1528524000

---

<div class="post-metadata">

**Author:** ![frankhochmuth](https://avatars.discourse-cdn.com/v4/letter/f/ad7895/32.png) [@frankhochmuth](https://community.influxdata.com/u/frankhochmuth)\
**Post date:** [June 9, 2018, 12:50pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/6 "2018-06-09T12:50:00Z")

</div>

Found the problem. It appears that the \_convert\_timestamp method of the line\_protocol.py is unable to handle non integer unix timestamps on the Raspberry, while it has no problems with non ints on the Windows and Ubuntu machines. Extra-formatting the timestamps with int() has fixed it.

---

<div class="post-metadata">

**Author:** ![noahcrowley](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/noahcrowley/32/818_2.png) [@noahcrowley](https://community.influxdata.com/u/noahcrowley)\
**Post date:** [June 11, 2018, 1:27pm UTC](https://community.influxdata.com/t/unexpected-behaviour-when-using-python-influxdb-client-on-raspberry/5460/7 "2018-06-11T13:27:28Z")

</div>

Glad you figured it out! Would you mind [opening a GitHub issue](https://github.com/influxdata/influxdb-python/issues) so the library maintainers are aware of the issue?
