CX_Freeze Fatal Python error: Py_Initialize: unable to get locale encoding

I am trying to use CX_Freeze to distribute Python code for multiple platforms. Everything went well on windows, but I got stuck trying to use CX_Freeze 5 on Ubuntu 14.04 LTS with python 3.4. I can run CX_Freeze without error, however when I run the resulting binary, I get

/Desktop/cx/cx_Freeze/samples/simple/build/exe.linux-i686-3.4$ ./hello
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)

      

This even happens with the "simple" example included in CX_Freeze (as well as my program), so I believe the problem is with my installation.

I was able to install CX_Freeze using this https://bitbucket.org/anthony_tuininga/cx_freeze/issue/32/cant-compile-cx_freeze-in-ubuntu-1304 workaround.

I read that CX_Freeze may have difficulty finding modules imported into python and that the solution is to add these files manually to the setup.py file and put the files in the same folder, however there are no encodings. py in the \ usr \ lib \ python3.4 folder, however there is a \ usr \ lib \ python3.4 \ encodings folder.

I'm sure my problem is that I have no idea what I am doing, but I followed all the installation instructions as best I could and still ran into this problem. After two days of looking, I haven't found a good answer yet, so I'm going to ask here. If the answer is found, it might help someone else as well. Thanks for any advice you can give.

Edit: Judging by the number of views this post has received, this is not a very common problem, however I have found a solution and I want to share it with the hope that it helps someone. The solution was to use cx_Freeze 4.3.3 instead of 5. You can find version 4.3.3 here as tar.gz file https://pypi.python.org/pypi?:action=display&name=cx_Freeze&version=4.3.3 . Then you need to make the changes described in the first link in this post to make the build correct. This solved the problem for me on Linux, but not OSX. Good luck!

+3


source to share





All Articles