lab hack: influxdb python module

Was trying to load some data into influxdb using a python3 script and got some errors. How the error was discovered – no module named install – influxdb will not work with python3

scl enable rh-python36 bash
python3 -V
Python 3.6.9

mkdir pydev
cd pydev/
python3 -m venv py36-venv
source py36-venv/bin/active
bash: py36-venv/bin/active: No such file or directory

source py36-venv/bin/activate
(py36-venv) 
(py36-venv) 
(py36-venv) python3 -m install python3-influxdb
/home/labadmin/Downloads/pydev/py36-venv/bin/python3: No module named install

(py36-venv) python3 -m install python3-influxdb-5.2.0
/home/labadmin/Downloads/pydev/py36-venv/bin/python3: No module named install
(py36-venv) exit

So lets begin the hacked solution, by enabling rh-python36 after having updated the @developers repo

subscription-manager repos --enable rhel-7-server-optional-rpms \
--enable rhel-server-rhscl-7-rpms
yum -y install @development

With that repo enabled we should be good on for python36, heres what happened next.

Proposed Solution:

[root@rhel75lab]# scl enable rh-python36 bash
[root@rhel75lab]# pip install influxdb
Collecting influxdb
  Downloading https://files.pythonhosted.org/packages/ef/02/da676b46a3c7b7387151554bd71a15d455ec512222f7f5171ae8607522aa/influxdb-5.2.3-py2.py3-none-any.whl (73kB)
    100% |████████████████████████████████| 81kB 1.1MB/s 
Collecting pytz (from influxdb)
  Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
    100% |████████████████████████████████| 512kB 1.1MB/s 
Collecting six>=1.10.0 (from influxdb)
  Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
Collecting requests>=2.17.0 (from influxdb)
  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
    100% |████████████████████████████████| 61kB 2.1MB/s 
Collecting python-dateutil>=2.6.0 (from influxdb)
  Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
    100% |████████████████████████████████| 235kB 696kB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests>=2.17.0->influxdb)
  Downloading https://files.pythonhosted.org/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539/urllib3-1.25.7-py2.py3-none-any.whl (125kB)
    100% |████████████████████████████████| 133kB 1.0MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.17.0->influxdb)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 1.9MB/s 
Collecting idna<2.9,>=2.5 (from requests>=2.17.0->influxdb)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 2.0MB/s 
Collecting certifi>=2017.4.17 (from requests>=2.17.0->influxdb)
  Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
    100% |████████████████████████████████| 163kB 1.3MB/s 
Installing collected packages: pytz, six, urllib3, chardet, idna, certifi, requests, python-dateutil, influxdb
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 influxdb-5.2.3 python-dateutil-2.8.1 pytz-2019.3 requests-2.22.0 six-1.13.0 urllib3-1.25.7
You are using pip version 9.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Upgrade for pip is required since it pulled from an old repo

[root@rhel75lab]# pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 748kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-19.3.1
[root@rhel75lab]# pip install influxdb
Requirement already satisfied: influxdb in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (5.2.3)
Requirement already satisfied: requests>=2.17.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2.22.0)
Requirement already satisfied: python-dateutil>=2.6.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2.8.1)
Requirement already satisfied: six>=1.10.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (1.13.0)
Requirement already satisfied: pytz in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2019.3)
Requirement already satisfied: certifi>=2017.4.17 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (2019.11.28)
Requirement already satisfied: idna<2.9,>=2.5 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (1.25.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (3.0.4)
[root@rhel75lab]# pip install --upgrade influxdb
Requirement already up-to-date: influxdb in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (5.2.3)
Requirement already satisfied, skipping upgrade: pytz in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2019.3)
Requirement already satisfied, skipping upgrade: python-dateutil>=2.6.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2.8.1)
Requirement already satisfied, skipping upgrade: six>=1.10.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (1.13.0)
Requirement already satisfied, skipping upgrade: requests>=2.17.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2.22.0)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (2019.11.28)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (3.0.4)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (1.25.7)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (2.8)

Installing tox

[root@rhel75lab]# pip install tox
Collecting tox
  Downloading https://files.pythonhosted.org/packages/77/a7/a5b721d9bf955edfe36013e5ecc9136fc6b2fef622ab1797ff0560273d8e/tox-3.14.3-py2.py3-none-any.whl (80kB)
     |████████████████████████████████| 81kB 892kB/s 
Collecting py<2,>=1.4.17
  Downloading https://files.pythonhosted.org/packages/99/8d/21e1767c009211a62a8e3067280bfce76e89c9f876180308515942304d2d/py-1.8.1-py2.py3-none-any.whl (83kB)
     |████████████████████████████████| 92kB 2.3MB/s 
Requirement already satisfied: six<2,>=1.0.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from tox) (1.13.0)
Collecting packaging>=14
  Downloading https://files.pythonhosted.org/packages/d8/5b/3098db49a61ccc8583ffead6aedc226f08ff56dc03106b6ec54451e27a30/packaging-20.0-py2.py3-none-any.whl
Collecting pluggy<1,>=0.12.0
  Downloading https://files.pythonhosted.org/packages/a0/28/85c7aa31b80d150b772fbe4a229487bc6644da9ccb7e427dd8cc60cb8a62/pluggy-0.13.1-py2.py3-none-any.whl
Collecting filelock<4,>=3.0.0
  Downloading https://files.pythonhosted.org/packages/93/83/71a2ee6158bb9f39a90c0dea1637f81d5eef866e188e1971a1b1ab01a35a/filelock-3.0.12-py3-none-any.whl
Collecting importlib-metadata<2,>=0.12; python_version < "3.8"
  Downloading https://files.pythonhosted.org/packages/d7/31/74dcb59a601b95fce3b0334e8fc9db758f78e43075f22aeb3677dfb19f4c/importlib_metadata-1.4.0-py2.py3-none-any.whl
Collecting toml>=0.9.4
  Downloading https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl
Collecting virtualenv>=16.0.0
  Downloading https://files.pythonhosted.org/packages/05/f1/2e07e8ca50e047b9cc9ad56cf4291f4e041fa73207d000a095fe478abf84/virtualenv-16.7.9-py2.py3-none-any.whl (3.4MB)
     |████████████████████████████████| 3.4MB 576kB/s 
Collecting pyparsing>=2.0.2
  Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
     |████████████████████████████████| 71kB 1.6MB/s 
Collecting zipp>=0.5
  Downloading https://files.pythonhosted.org/packages/f4/50/cc72c5bcd48f6e98219fc4a88a5227e9e28b81637a99c49feba1d51f4d50/zipp-1.0.0-py2.py3-none-any.whl
Collecting more-itertools
  Downloading https://files.pythonhosted.org/packages/bc/e2/3206a70758a21f9878fcf9478282bb68fbc66a5564718f9ed724c3f2bb52/more_itertools-8.1.0-py3-none-any.whl (41kB)
     |████████████████████████████████| 51kB 2.0MB/s 
Installing collected packages: py, pyparsing, packaging, more-itertools, zipp, importlib-metadata, pluggy, filelock, toml, virtualenv, tox
  Found existing installation: virtualenv 15.1.0
    Uninstalling virtualenv-15.1.0:
      Successfully uninstalled virtualenv-15.1.0
Successfully installed filelock-3.0.12 importlib-metadata-1.4.0 more-itertools-8.1.0 packaging-20.0 pluggy-0.13.1 py-1.8.1 pyparsing-2.4.6 toml-0.10.0 tox-3.14.3 virtualenv-16.7.9 zipp-1.0.0

Uninstalling influxdb (to clear the older version)

[root@rhel75lab]# pip uninstall influxdb
Uninstalling influxdb-5.2.3:
  Would remove:
    /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/influxdb-5.2.3.dist-info/*
    /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/influxdb/*
Proceed (y/n)? y
  Successfully uninstalled influxdb-5.2.3


Install influxdb name module

[root@rhel75lab]# pip install influxdb
Collecting influxdb
  Using cached https://files.pythonhosted.org/packages/ef/02/da676b46a3c7b7387151554bd71a15d455ec512222f7f5171ae8607522aa/influxdb-5.2.3-py2.py3-none-any.whl
Requirement already satisfied: python-dateutil>=2.6.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2.8.1)
Requirement already satisfied: six>=1.10.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (1.13.0)
Requirement already satisfied: pytz in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2019.3)
Requirement already satisfied: requests>=2.17.0 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from influxdb) (2.22.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (1.25.7)
Requirement already satisfied: certifi>=2017.4.17 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (2019.11.28)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from requests>=2.17.0->influxdb) (2.8)
Installing collected packages: influxdb
Successfully installed influxdb-5.2.3

Now having resolved that, I can use the injector.py script to load json data into influxdb

$ python3 injector41.py < /tmp/rhel75lab_20200115_0139.json
host=localhost port=8086 user=root password=passwd123 dbname=dblinuxsrv

Leave a Reply

RELATED POST

Reverse Proxy Apache

Neat trick after subdomain is created, want to preserve the url for example lets look at this lab hack (its…

scp to a port

Quick reminder on how to transfer a file to a specific port, the option is upper -P $ scp -P…

Install Apache using Puppet Master

In this vast world of orchestration & automation tools and techniques, here is a quick one on how to get…

Using nmon & nmon visualizer

A great way to visualize nmon data is using Nigel Griffiths nmon visualizer java tool #java -DfontSize=16 -jar NMONVisualizer_.jar