为什么我在安装了cx_Freeze之后会得到一个“没有模块的cx_Freeze”错误?

时间:2022-05-28 10:54:16

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:

我正在尝试编译一个python程序,我使用的是python 3.2。所以我下载了cx_freeze并安装了它。当我尝试运行设置时。cmd的py表示

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

我已经删除了cx_freeze,并试图重新安装它,但这次,在“选择cx_freeze应该安装的位置”部分安装中,我从registry中选择了python(这是我以前所做的一切),还选择了“从另一个位置选择python”(并选择了C:\python32\目录)。然后我得到了这个错误:

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

注意:在我的设置。py文件如下:

from cx_freeze import *

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

1 个解决方案

#1


15  

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%").

因此,当您输入“python设置”时。py构建到cmd,它试图做的是寻找python。在您所在的文件夹中的exe,如果没有找到它,则查找系统路径(您可以使用“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.

它在那里查找,找到python并运行它——但是python没有cx_Freeze。为什么?因为系统路径中的python是一个较老的版本!对我来说是2。6.5,尽管我用了3。3。这个老版本没有cx_Freeze,因为我把它安装到3。3。这也解释了为什么在空闲工作中尝试“导入cx_Freeze”没有问题。

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

要查看哪个版本的python cmd正在调用,只需在cmd中输入“python”,它就会显示给您。

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

好的,那么快速的解决方案就是添加到所需的python.exe的完全绝对路径。对于python 3.3:

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

长期的解决方案是将python 3.3添加到系统路径中。我自己也没做过,但这应该是关于如何做它的信息。

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

这是一个迟来的答案,但我希望这至少能帮助到其他人。享受你的cx_Freeze

#1


15  

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%").

因此,当您输入“python设置”时。py构建到cmd,它试图做的是寻找python。在您所在的文件夹中的exe,如果没有找到它,则查找系统路径(您可以使用“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.

它在那里查找,找到python并运行它——但是python没有cx_Freeze。为什么?因为系统路径中的python是一个较老的版本!对我来说是2。6.5,尽管我用了3。3。这个老版本没有cx_Freeze,因为我把它安装到3。3。这也解释了为什么在空闲工作中尝试“导入cx_Freeze”没有问题。

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

要查看哪个版本的python cmd正在调用,只需在cmd中输入“python”,它就会显示给您。

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

好的,那么快速的解决方案就是添加到所需的python.exe的完全绝对路径。对于python 3.3:

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

长期的解决方案是将python 3.3添加到系统路径中。我自己也没做过,但这应该是关于如何做它的信息。

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

这是一个迟来的答案,但我希望这至少能帮助到其他人。享受你的cx_Freeze