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

Question:

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("")] ,
)    
Asked By: bla bla

||

Answers:

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:python33python 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

Answered By: Slobodan Stevic

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.

Answered By: double0darbo

If you are on a Mac and use Python3, install cx_Freeze like this:
python3 -m pip install --upgrade cx_Freeze
then run python3 setup.py build

Answered By: andream
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.