ImportError: /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block

C++
I had a similar issue where I was unable to import cv2. I can import opencv in console
I was importing tensorflow before cv2. 
For some reason switching the order (importing cv2 first) worked. 
I am not sure how it worked but it might help you. 
Source

Also in C++: