Splunk Dev

ImportError: No module named _codecs_tw, when calling encoding module in an apps script

lhy719
New Member

Please help me on this.

I need to transform encoding from utf-8 to big5 in a app script. However it does nothing with no error shown. Finally I find that's due to lacking some so files in $SPLUNKHOME/lib/python2.6/lib-dynload/, such as _codecs_cn.so, _codecs_hk.so, _codecs_iso2022.so, _codecs_jp.so, _codecs_kr.so, _codecs_tw.so, _multibytecodec*.so.

A simple test script as following,
import sys, time, os, encodings
from encodings import big5
print encodings.big5.getregentry()

Run it by, /opt/splunk/bin/splunk cmd python /opt/splunk/etc/apps/AlertThrottle/bin/a-test.py
Then I get ImportError: No module named _codecs_tw.

I've try to put those missing files from other python package. After that, script shows 'undefined symbol: PyUnicodeUCS4_Splitlines', which seems related to unicodeobject.h file.

Meanwhile, encoding and decoding of unicod fail too. A script I run as following,
Big5txt = unicode(msg[:65],'utf-8').encode('big5')
LookupError: unknown encoding: big5

Is it posible to get those Asian encoding works in python build in splunk?

Tags (1)
0 Karma

vipexxe
New Member

我也遇到相同的问题 ImportError: No module named _codecs_cn

请问你的问题解决了吗? 如果你解决了,可以麻烦你把方法发送到 vipexxe at 126 dot com 吗? 谢谢!!!

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...