首页 \ 问答 \ 在spyder中使用cx_freeze(using cx_freeze in spyder)

在spyder中使用cx_freeze(using cx_freeze in spyder)

我使用pip安装了cx_Freeze:

C:\Users\Sarah\Documents\PythonScripts>python -m pip install cx_Freeze --upgrade
Collecting cx_Freeze
  Downloading cx_Freeze-5.0.2-cp36-cp36m-win_amd64.whl (162kB)
Installing collected packages: cx-Freeze
Successfully installed cx-Freeze-5.0.2

但是,当我尝试执行脚本时出现此错误:

setup.py build
Traceback (most recent call last):
  File "C:\Users\Sarah\Documents\PythonScripts\setup.py", line 9, in <module>
    from cx_freeze import setup, Executable
ImportError: No module named cx_freeze

当我检查系统路径时,我得到所有这些信息

print (sys.path)
['', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site', 'C:\\Users\\Sarah\\Documents\\PythonScripts', 'C:\\Users\\Sarah\\Anaconda3\\python36.zip', 'C:\\Users\\Sarah\\Anaconda3\\DLLs', 'C:\\Users\\Sarah\\Anaconda3\\lib', 'C:\\Users\\Sarah\\Anaconda3', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\Sarah\\.ipython']

我假设不知何故,cx_freeze模块的路径在这里丢失了。 我真的很感谢一些简单的(新手用户)关于如何解决这个问题的想法。

我试图将文件夹cx-freeze复制到PythonScripts文件夹,但这没有帮助。


I installed cx_Freeze using pip:

C:\Users\Sarah\Documents\PythonScripts>python -m pip install cx_Freeze --upgrade
Collecting cx_Freeze
  Downloading cx_Freeze-5.0.2-cp36-cp36m-win_amd64.whl (162kB)
Installing collected packages: cx-Freeze
Successfully installed cx-Freeze-5.0.2

However, I get this error when I try to execute a script:

setup.py build
Traceback (most recent call last):
  File "C:\Users\Sarah\Documents\PythonScripts\setup.py", line 9, in <module>
    from cx_freeze import setup, Executable
ImportError: No module named cx_freeze

When I check the system path, I get all this information

print (sys.path)
['', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site', 'C:\\Users\\Sarah\\Documents\\PythonScripts', 'C:\\Users\\Sarah\\Anaconda3\\python36.zip', 'C:\\Users\\Sarah\\Anaconda3\\DLLs', 'C:\\Users\\Sarah\\Anaconda3\\lib', 'C:\\Users\\Sarah\\Anaconda3', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\Sarah\\.ipython']

I am assuming that somehow, the path to the cx_freeze module is lost in here somewhere. I would really appreciate some simple (novice user) ideas for how to go about fixing this.

I tried copying the folder cx-freeze to the PythonScripts folder but that didn't help.


原文:https://stackoverflow.com/questions/45417577
更新时间:2023-04-17 19:04

最满意答案

您可以使用特定于目标的变量值 。 例:

CXXFLAGS = -g3 -gdwarf2
CCFLAGS = -g3 -gdwarf2

all: executable

debug: CXXFLAGS += -DDEBUG -g
debug: CCFLAGS += -DDEBUG -g
debug: executable

executable: CommandParser.tab.o CommandParser.yy.o Command.o
    $(CXX) -o output CommandParser.yy.o CommandParser.tab.o Command.o -lfl

CommandParser.yy.o: CommandParser.l 
    flex -o CommandParser.yy.c CommandParser.l
    $(CC) -c CommandParser.yy.c

记住在所有的编译命令中使用$(CXX)或$(CC)。

然后,'make debug'将会有额外的标志,如-DDEBUG和-g,其中'make'不会。

在附注中,您可以像其他帖子所建议的那样使您的Makefile更简洁。


You can use Target-specific Variable Values. Example:

CXXFLAGS = -g3 -gdwarf2
CCFLAGS = -g3 -gdwarf2

all: executable

debug: CXXFLAGS += -DDEBUG -g
debug: CCFLAGS += -DDEBUG -g
debug: executable

executable: CommandParser.tab.o CommandParser.yy.o Command.o
    $(CXX) -o output CommandParser.yy.o CommandParser.tab.o Command.o -lfl

CommandParser.yy.o: CommandParser.l 
    flex -o CommandParser.yy.c CommandParser.l
    $(CC) -c CommandParser.yy.c

Remember to use $(CXX) or $(CC) in all your compile commands.

Then, 'make debug' will have extra flags like -DDEBUG and -g where as 'make' will not.

On a side note, you can make your Makefile a lot more concise like other posts had suggested.

相关问答

更多
  • 你绝对可以这样做。 你想要的三件事是.PHONY目标 (因此make不认为windows-release等是真实文件), 特定于目标的变量值 (因此你可以根据运行的目标设置不同的变量)和Secondary Expansion,因为否则,先决条件的评估发生在特定于目标的上下文之外,因此特定于目标的变量不起作用)。 哪个组合得到这样的东西: windows-release: CC:=... windows-release: CFLAGS:=... windows-release: OUTDIR:=windows ...
  • 你对每个目标有不同的Application.mk文件吗? 没有。独立的子目录,所有的都有自己的Android.mk(共享和静态库),但我只有一个Application.mk。 我的Application.mk只是: APP_STL := gnustl_static APP_OPTIM := debug 我仍然不确定什么是构建我们的.so文件的Debug版本和最新版本的最佳方法。 每次手工更换东西都变老了。 至少对我来说,使用jni / Android.mk + Application.mk布局有点分散。 ...
  • 假设你在谈论autoconf / automake: 为什么不保持调试符号,让任何不喜欢它们的人make install-strip ? Assuming you're talking about autoconf/automake: Why not just keep the debugging symbols and let anybody who doesn't like them make install-strip?
  • 这可能很小,但它加起来了别人在这里说的话。 QA测试版本的优点之一是随着时间的推移,内置的软件调试和日志记录能力将由于开发人员的需求而有所改进,这些开发人员需要弄清楚为什么在QA中出现问题。 开发人员需要调试发布版本的程度越多,客户开始出现问题的更好工具。 当然,开发人员在开发周期的一部分没有理由发布版本。 此外,我不知道任何软件公司有足够的周期来支付在调试时将QA从调试开始转移到版本测试期间的一半。 做完全质量保证周期是很少发生的事情。 This might be minor, but it adds u ...
  • 您可以使用特定于目标的变量值 。 例: CXXFLAGS = -g3 -gdwarf2 CCFLAGS = -g3 -gdwarf2 all: executable debug: CXXFLAGS += -DDEBUG -g debug: CCFLAGS += -DDEBUG -g debug: executable executable: CommandParser.tab.o CommandParser.yy.o Command.o $(CXX) -o output CommandPars ...
  • 调试和发布目标可以使用不同的宏(例如NDEBUG )和不同的优化级别进行构建。 您通常不希望混合调试和释放目标文件,因此需要将它们编译到不同的目录中。 我经常以这种方式为不同的构建模式使用不同的顶级构建目录: BUILD := debug BUILD_DIR := build/${BUILD} 和编译器标记这样: cppflags.debug := cppflags.release := -DNDEBUG cppflags := ${cppflags.${BUILD}} ${CPPFLAGS} cxxf ...
  • 在XCode中,我们有针对每个应用程序的目标。 默认情况下,您为每个应用程序获取一个目标 使用xCode中的内置选项复制目标。 所以一个用于本地测试,另一个用于实时模式。 您也可以在这两个目标处于发布模式。 xCode中的每个目标都有单独的.plist文件来定义一些设置,并且让您的代码库相同。 现在把你的本地服务器url放到target_test的plist和真正的服务器url中。 您的代码应在运行时从相应的plist读取。 看一看 IN XCode we have targets for every ap ...
  • 所以你正在做的是创建一个目标变量 ,它只在debug配方的范围内有效(而不是它的子配方)。 您可能想要做的是如下行: ifeq ($(filter debug,$(MAKECMDGOALS)),debug) EXEC_DIR = ../../../../Bin/linux/debug/ OBJ_DIR = ../../../../Bin/linux/debug/objs ... endif 然后将$(OBJ_DIR)到所有目标文件中。 这解决了Etan提到的不重建的源文件。 So ...
  • 如果你真的需要进行源内构建并拥有单独的输出目录,我认为你需要将每个文档的条件更改为 CONFIG(debug, debug|release){ DESTDIR = ./debug OBJECTS_DIR = debug/.obj MOC_DIR = debug/.moc RCC_DIR = debug/.rcc UI_DIR = debug/.ui } CONFIG(release, debug|release){ DESTDIR = ./release ...
  • 是的,这是完全正常的。 这种情况通常是由像Matrix和Vector这样的类的使用类似普通数据类型(即支持+, - ,*等)和ASSERTs引起的。 类类型导致如此缓慢的原因是因为没有内联代码被内联到释放中的内联代码中。 这可能导致巨大的速度差异,令人惊讶的是如此。 ASSERTs是额外的工作来检查事物的安全性。 额外的工作意味着额外的处理时间,因此事情变慢。 由于已经是趋势,缺乏优化也无济于事。 尽管在某种程度上,这反映在缺乏内联(这是一种优化)。 Yes it is entirely normal. S ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)