New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cx_Freeze: “No module named 'codecs'” Windows 10 #325

Closed
Alegruz opened this Issue Nov 10, 2017 · 28 comments

Comments

Projects
None yet
9 participants
@Alegruz

Alegruz commented Nov 10, 2017

https://stackoverflow.com/questions/47223944/cx-freeze-no-module-named-codecs-windows-10

The build itself has no problem I think, but as soon as I open the .exe file of the game, it crashes.

Fatal Python error: Py_Initialize: unable to load the file system codec
Traceback (most recent call last):
File "C:\Users\jinju\AppData\Local\Programs\Python\Python35-32\lib\encodings_init_.py", line 31, in
ImportError: No module named 'codecs'

@anthony-tuininga

This comment has been minimized.

Owner

anthony-tuininga commented Nov 11, 2017

The code for setting the initial path is required in the 5.x branch as well. Please confirm that this addresses your issue. Thanks!

@Alegruz

This comment has been minimized.

Alegruz commented Nov 12, 2017

@anthony-tuininga
I'm terribly sorry, but can you tell me how to set this code? I have only studied python this year and never had I learn C...
Should I make a new C file with the name Common.c in C:\Users\username\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\cx_Freeze\bases?

@k3it

This comment has been minimized.

k3it commented Nov 16, 2017

I just ran into the same issue with the codecs module. checked out and rebuilt v5.x branch and it fixed the problem. also handling of non-ascii characters in path names appears to be working fine now.

@k3it

This comment has been minimized.

k3it commented Nov 18, 2017

@anthony-tuininga

This comment has been minimized.

Owner

anthony-tuininga commented Nov 19, 2017

Based on the results here I'll make a new 5.1.1 release soon (probably next week).

@Foxhound013

This comment has been minimized.

Foxhound013 commented Nov 22, 2017

k3it, This is probably a silly question but could you direct me on how to compile the 5.x branch? I'm having the same issue. (If 5.1.1 is getting released within the next week, I may just wait)

@k3it

This comment has been minimized.

k3it commented Nov 22, 2017

@Foxhound013 clone the cx_Freeze repository. then git checkout v5.x and then follow the build instructions in README.md

@DSPGuy

This comment has been minimized.

DSPGuy commented Nov 30, 2017

I just ran into the same issue on my Win10 machine with Python 3.5.. Is there a projection on when the fix will be publicly available, and how I would be able to download it? I don't have a C or C++ SDK installed on my machine, so will have to wait for the fixed cx_freeze to be available.

@k3it

This comment has been minimized.

k3it commented Nov 30, 2017

the c compiler takes only a few min to install and the build script even prints the download URL.. I guess this is a volunteer project, things get done when they get done ;)

@DSPGuy

This comment has been minimized.

DSPGuy commented Nov 30, 2017

Anthony,
Thanks for the response. Two items I'd like some clarification on:

  1. Which C compiler are you referring to? (I haven't coded in over 12 years.)
  2. Also, when I run "python setup.py build", I don't see a URL. Are you referring to a different build script?
@DSPGuy

This comment has been minimized.

DSPGuy commented Dec 1, 2017

Foxhound013,
I just downloaded the Code::Blocks C/C++ compiler. You were right. Just a few minutes to install. I guess things have changed significantly since 2004 when I last coded C. Procuring and installing a C compiler back then was a major undertaking. I cloned the 5.x branch to my Windows 10 machine. No (known) problem. Not familiar with the command "git checkout v5.x". Looks like some sort of Linux version control get command which would not apply to my Windows 10 situation. The only readme.md which I found in my cloned 5.x set really didn't discuss the process for building the 5.1 code. Surely I'm missing something here. Not sure what it is. Thanks.

@k3it

This comment has been minimized.

k3it commented Dec 1, 2017

@DSPGuy great, I see you are new to github. this is a bit challenging at first but it will grow on you :) I would recommend installing http://desktop.github.com . that should make git command available on win10, as well as some other GUI based tools. (I used visual studio from MS to build, which free/quick install also)..

@Oxyo78

This comment has been minimized.

Oxyo78 commented Dec 2, 2017

I got a problem with th build version of this version (6.0b1), he work fine, on my computer, i can launch the exe, but when I download the build folder on a other computer I got an error :
cx_freeze error

@juedi998

This comment has been minimized.

juedi998 commented Dec 4, 2017

Hey anthony, I just ran into the same issue on win7, i try using the pip update to 6x or 5.11, but the return "Requirement already up-to-date", and i has been modified the "macdist.py"file. but the error still there.can u help me?

@DSPGuy

This comment has been minimized.

DSPGuy commented Dec 4, 2017

I don't know that I need the very latest version of cx_freeze. Is there another recent version which stable and working without this, or other critical issues which I could use? 5.0 for instance?

@k3it

This comment has been minimized.

k3it commented Dec 4, 2017

if you are having trouble with the 'git checkout v5.x' command, may be you can try downloading the branch directly https://github.com/anthony-tuininga/cx_Freeze/archive/v5.x.zip you'd still need to run the build commands..

@DSPGuy

This comment has been minimized.

DSPGuy commented Dec 5, 2017

k3it,
Thanks for the alternate approach. I downloaded the .zip . It appears that it would require a C-based build as you mentioned. I'd really prefer a .whl file installation of a working version of cx_freeze for Win 10, if possible. I've got that process down.

Please be aware that as of a week ago, I had never entered into the Python world. I'm trying to wade through learning Python, pip, cx_freeze, my company's library of python scripts, .whl files, and github, among other things. A bit overwhelming, especially since I'm working as a lone wolf here - not in a team of experienced Python programmers. I'd prefer to not have to get the build from C code working. There are bound to be issues there. So I hope you understand my hopes of finding a quick, straightforward way to install a working version of cx_freeze. A .whl file would do it, as I've figured out the tools for that. Reaching a standalone executable is a critical part of this entire effort. And for my Python 3.5.4 installation, cx_freeze is the only way I know to get there.
Thank you,
DSP_Guy

@DSPGuy

This comment has been minimized.

DSPGuy commented Dec 5, 2017

Well, three seconds after submitting the prior message I realized that there's a good chance that pypi.python.org would have what I'm looking for. I did find cx_freeze 5.02 there in a .whl at https://pypi.python.org/pypi/cx_Freeze/5.0.2 . I downloaded it, pip uninstalled the previous cx_freeze, and then pip installed the 5.02. The install went OK. The building of the .exe of a sample python script seemed to go OK. But when I tried to run the resultant executable, I got the same error message "No module named 'codecs' ".

Is there a version of cx_freeze which works on Win 10?

@k3it

This comment has been minimized.

k3it commented Dec 5, 2017

@DSPGuy sorry that things are not working out. I'm not sure why you are venturing into all kinds strange paths, such as attempting to find a back level version that runs on win10, when the solution provided here is straight forward and requires just a couple of commands to execute. You would not need to look at any .py or .c code to do that. I think you really need to learn how to run builds from github, instead of waiting for someone to do it for you. Or use commercial software and not rely on open source stuff.

@DSPGuy

This comment has been minimized.

DSPGuy commented Dec 5, 2017

It's just that not being familiar with the tools, the meanings of some of the helpful suggestions are not as clear to me as to someone more familiar with the processes and lingo. I too wish it were going more smoothly. I don’t like having to ask for help. so very much appreciate any help offered.

I did go back to the readme.md file and saw the two commands:
python setup.py build
python setup.py install
I ran them, and as far as I could tell, they both ran without issue. The last few output lines from the install command were:

Installed c:\program files\python35\lib\site-packages\cx_freeze-5.1.1-py3.5-win-amd64.egg
Processing dependencies for cx-Freeze==5.1.1
Finished processing dependencies for cx-Freeze==5.1.1

Apparently, it built cx_freeze-5.1.1-py3.5-win-amd64.egg and put it in the proper site-packages folder. But I tried using cx-freeze again after all that, and ended up with the exact same error message "No module named 'codecs' .

I am trying to learn and do all this and feel I'm getting close. I'm sure it's not that difficult once familiarity takes place.

@k3it

This comment has been minimized.

k3it commented Dec 5, 2017

i think you are really close to getting it to work. it looks like the build was successful.

sometimes there is a conflict with the previously installed module. may be try to create a brand new virtualenv and run a clean build/install in it. or pip uninstall the existing versions.

@DSPGuy

This comment has been minimized.

DSPGuy commented Dec 5, 2017

Apparently I was. I did a pip uninstall of cx_freeze, and rebuilt/reinstalled cx_freeze. That did it! Easy as py!
Thanks for putting up with me. You know us nubes - always taking wrong turns.

BTW, there was a suggestion above that downloading the Windows desktop github app will provide me with command line git capability. I found that I had to also download and install Git-2.15.1.2-32-bit.exe from git-scm.com to actually get command line capability. The git commands seemed to work. But there was some quirk when I tried getting help on a command, such as "git help clone". I'd get a weird response indicating a likely version compatibility problem with a cygwin dll . I don't even have cygwin installed. A google search on it shows that several other indicated that they're run into the same thing. I installed cygwin, but that didn't help. NOT asking for help on this at all. This wouldn't be the right place for it. Just an interesting point. Below is the response I was getting:

1 [main] sh (502608) C:\Program Files (x86)\Git\usr\bin\sh.exe: *** fatal error - cygheap base mismatch detected - 0xE5D408/0xFAD408.
This problem is probably due to using incompatible versions of the cygwin DLL. Search for cygwin1.dll using the Windows Start->Find/Search facility and delete all but the most recent version. The most recent version should reside in x:\cygwin\bin, where 'x' is the drive on which you have installed the cygwin distribution. Rebooting is also suggested if you are unable to find another cygwin DLL.

@k3it

This comment has been minimized.

k3it commented Dec 5, 2017

great news. practically nub here myself , but sometimes get lucky and stuff starts to work OK :)

@thearttrooper

This comment has been minimized.

thearttrooper commented Dec 7, 2017

The proposed solution of: download and build cx_Freeze from the source worked for me on Windows 10. I have Visual Studio 2015 Update 3 installed and Python 3.6.2. I started with: pip3 uninstall cx_Freeze. Then I git cloned the source; setup Visual Studio to run from the command line; added the location of RC.EXE to my path (it's in the Windows SDK folder structure); ran python setup.py build; ran python setup.py install. Lastly I built my script into an EXE and ran it. I had to modify my script because I use file. See: http://cx-freeze.readthedocs.io/en/latest/faq.html

@anthony-tuininga

This comment has been minimized.

Owner

anthony-tuininga commented Dec 9, 2017

I just pushed a change to the v5.x branch that should resolve this issue for everyone. I've tried it on Windows as well and it seems to work fine. Assuming no further issues I'll release 5.1.1 sometime next week.

@Alegruz

This comment has been minimized.

Alegruz commented Dec 10, 2017

Worked fine for me!

https://github.com/Alegruz/QUATRIS/

thanks for the help, anthony!

@anthony-tuininga

This comment has been minimized.

Owner

anthony-tuininga commented Dec 16, 2017

cx_Freeze 5.1.1 has been released with this fix in it.

@speedpacer

This comment has been minimized.

speedpacer commented Dec 16, 2017

Sorry to have to report this but I followed along here and uninstalled the 5.0 version as suggested and compiled 5.1 from source and I was able to overcome this issue, but when I copy the resulting files into a directory in my path and try to execute it from another directory, the error comes back. I may be doing it wrong... I'm using Python 3.6.3 and Windows 10 and creating a console app.

update: I managed to get it working using the dist_msi method and installing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment