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

bla bla picture bla bla · Dec 17, 2012 · Viewed 28.5k times · Source

I am trying to compile a python program and I am using python 3.2. So I downloaded cx_freeze and installed it. When I try to run the setup.py in cmd it says:

"importerror: no module named cx_freeze" 

I have removed cx_freeze and tried to re-install it, this time however, in the "select the location where cx_freeze should be installed" part of the installation I selected python from registry (which is all I did before) and also selected "python from another location" (and choose my C:\python32\ directory). Then I got this error:

"There is a problum with this windows installation package. a program required for this install to complete could not be run."

note: in my setup.py file is the following:

from cx_freeze import *

Setup(
    name = "",
    version ="0.1",
    description ="",
    executables = [Executable("")] ,
)    

Answer

Slobodan Stevic picture Slobodan Stevic · May 26, 2013

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