Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python: how to add 'unicodedata' module to my current python lib

Currently I am using a python module 'requests' to handle some https issue.

My code works well on a windows machine. But when I copy all source codes to a linux machine and run all codes, there was a feedback ImportError: No module named unicodedata.

My python version is 2.7.4. But I found 'unicodedata' module first appeared in 2.5. So it is very strange why my current version doesn't include it.

Is there any method to solve this problem without updating the python version? Or say how can I port 'unicodedata' module to my current python lib? Thanks!

like image 449
liminche Avatar asked Sep 30 '22 13:09

liminche


1 Answers

1. Install unicodedata

On some Linux distro (as Fedora-26), unicodedata is provided by package python-libs

sudo dnf install python-libs

But you may attempt:

pip install unicodedata

or if not found:

pip install unicodedata2

2. Locate unicodedata

Your unicodedata.so (or unicodedata2.so) is in system directory:

/usr/lib64/python2.7/lib-dynload/unicodedata.so

If option --user used as in pip install --user unicodedata2, the library is in user directory:

$HOME/.local/lib/python2.7/site-packages/unicodedata2.so

You can use command locate unicodedata if you are still looking for this library.

3. Fix ImportError

To fix the issue ImportError: No module named unicodedata, you can create a symbolic link to the unicodedata.so library from your application library directory:

cd libs
ln -sv /usr/lib64/python2.7/lib-dynload/* .
like image 133
oHo Avatar answered Oct 02 '22 16:10

oHo