Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After reinstalled the python3.2, I got the error as below when call py3compile:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
LookupError: no codec search functions registered: can't find encoding

I know it may be the problem of missing environment variable. But I have no idea of how to fix it. I checked the env output and didn't find any PYTHONXXX variables.

share|improve this question

Mind that this is a late response, since someone has offered a bounty on this question. Also note that without reproducing this problem I can't verify if any solution works. I will just suggest a solution here, not provide one.

I think you have to set two variables as outlined here, because py3compile needs to know where certain resources are. It looks them up via these PYTHONXXX variables.


export PYTHONPATH='/usr/lib64/python3.21:/usr/lib64/python3.2/lib-dynload:/usr/lib64/python3.2/site-packages'
export PYTHONHOME='/usr/lib64/python3.2'

or rather

export PYTHONPATH='/path/to/pythondir:/path/to/pythondir/lib-dynload:/path/to/pythondir/site-packages'
export PYTHONHOME='/path/to/pythondir'

should do the trick.

share|improve this answer

Try following (replace opkg with your favorite package manager)

 # opkg install python3-modules
 # opkg install python3-misc
share|improve this answer
Not all package managers use directives like install. And, not all distros provide those packages. – HalosGhost Sep 10 '14 at 15:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.