问题
I'm using a Windows 7 machine with cx_Freeze 4.3.1 with Python 3.3, both Python and cx_Freeze are 32-bit versions. I've written a setup.py script that looks like this:
import sys
from cx_Freeze import setup, Executable
setup(
name = "Macro Generator",
version = "1.1",
description = "Writes Macros for you",
executables = [Executable("program.py")]
)
When I navigate to the setup.py file location and try to create this executable from the command prompt using:
python setup.py build
I receive the following error.
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from cx_Freeze import setup, Executable
ImportError: cannot import name setup
I've also tried to build executables out of some of the sample programs provided with the cx_Freeze download, but I receive the same error for those as well. I've uninstalled cx_Freeze and tried a different version, but the error persists.
Does anyone have any ideas?
Thanks, let me know if you need additional information.
回答1:
Resolved, I removed import sys
from my setup.py
file and the program compiled successfully.
来源:https://stackoverflow.com/questions/23771188/cx-freeze-importerror-cannot-import-name-setup