/usr/lib/x86_64-linux-gnu/libjemalloc.so.2: cannot allocate memory in static TLS block code example
Example: ImportError: /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block
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.