Why am I getting a "no module named cx_Freeze" error after installing cx_freeze?

I experienced the same issue with python version 3.8.

I found when updating cx_freeze using a compiler, it converted to a pip install, and somehow removed the site-packages path from the %PATH% environment variable for the anaconda environment I was operating in.

From marcelotduarte at github,

If you have a C compiler, you can test the development version: pip install -U git+https://github.com/marcelotduarte/cx_Freeze.git@develop

I uninstalled the module using pip uninstall cx_freeze, and then reinstalled using anaconda, conda install cx_freeze. This corrected the problem and aligned the path variables properly.


Finally found the solution to this problem! Been trying for two days and a programmer friend helped me (I'm not a programmer myself).

So, when you type in "python setup.py build" to cmd, what it tries to do is look for python.exe in the folder you are in, and if it doesn't find it there then looks to system paths (which you can access with the command "echo %PATH%").

So it looks there, it finds python and runs it - but python doesn't have cx_Freeze. Why? Because the python in the system path is an older version you have!! For me it was 2.6.5, despite me using 3.3. And this older version naturally didn't have cx_Freeze in it because I installed it to 3.3. This also explains why trying "import cx_Freeze" in IDLE works without problems.

To see which version of python cmd is calling, type only "python" in cmd and it will show you.

Ok, so the quick solution is to simply add the full absolute path leading to desired python.exe. For python 3.3 it's:

c:\python33\python setup.py build

The long-term solution is to add python 3.3 to your system paths. I haven't done it myself, but this should be the info on how to do it http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx

It's a late answer, but I hope this at least helps someone else. Enjoy your cx_Freeze