pyqtgraph 编译为可执行文件失败

Posted

技术标签:

【中文标题】pyqtgraph 编译为可执行文件失败【英文标题】:pyqtgraph compile to executable file fails 【发布时间】:2013-07-07 07:43:35 【问题描述】:

我想从pyqtgraph创建一个可执行文件,

我终于尝试了这个教程

http://www.pyqtgraph.org/Bundling%20applications%20with%20PyQtGraph_R16.pdf

在示例中的编译代码第一次运行后,教程说应该有类似的错误消息

Traceback (most recent call last):
File "simpleApp.pyw", line 6, in <module>
File "pyqtgraph\__init__.pyc", line 107, in <module>
File "pyqtgraph\__init__.pyc", line 89, in importAll
WindowsError: [Error 3] The system cannot find the path specified:
'D:\\xxxxxx\\SandBox\\src\\dist\\library.zip\\pyqtgraph\\graphicsItems/*.*'

但我明白了

 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 246, in <module>
 File "scipy\stats\distributions.pyc", line 16, in <module>
 File "scipy\optimize\__init__.pyc", line 148, in <module>
 File "scipy\optimize\_root.pyc", line 20, in <module>
 File "scipy\optimize\nonlin.pyc", line 122, in <module>
 File "scipy\sparse\__init__.pyc", line 193, in <module>
 File "scipy\sparse\csgraph\__init__.pyc", line 148, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 12, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 10, in __load
 File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path                
 (scipy\sparse           \csgraph\_shortest_path.c:14224)
 ImportError: No module named _validation
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
 File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\HistogramLUTItem.pyc", line 10, in <module>
 File "pyqtgraph\graphicsItems\GradientEditorItem.pyc", line 8, in <module>
 File "pyqtgraph\colormap.pyc", line 2, in <module>
 File "scipy\interpolate\__init__.pyc", line 160, in <module>
 File "scipy\interpolate\ndgriddata.pyc", line 10, in <module>
 File "scipy\interpolate\interpnd.pyc", line 12, in <module>
 File "scipy\interpolate\interpnd.pyc", line 10, in __load
 File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd (scipy\interpolate\interpnd.c:22803)
 File "scipy\spatial\__init__.pyc", line 87, in <module>
 File "scipy\spatial\kdtree.pyc", line 8, in <module>
 File "scipy\sparse\__init__.pyc", line 193, in <module>
 File "scipy\sparse\csgraph\__init__.pyc", line 148, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 12, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 10, in __load
 File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path (scipy\sparse   
 \csgraph\_shortest_path.c:14224)
 ImportError: No module named _validation
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\GraphicsLayout.pyc", line 6, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
 File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\GradientEditorItem.pyc", line 8, in <module>
 File "pyqtgraph\colormap.pyc", line 2, in <module>
 File "scipy\interpolate\__init__.pyc", line 160, in <module>
 File "scipy\interpolate\ndgriddata.pyc", line 10, in <module>
 File "scipy\interpolate\interpnd.pyc", line 12, in <module>
 File "scipy\interpolate\interpnd.pyc", line 10, in __load
 File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd (scipy\interpolate\interpnd.c:22803)
 File "scipy\spatial\__init__.pyc", line 87, in <module>
 File "scipy\spatial\kdtree.pyc", line 8, in <module>
 File "scipy\sparse\__init__.pyc", line 193, in <module>
 File "scipy\sparse\csgraph\__init__.pyc", line 148, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 12, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 10, in __load
 File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path (scipy\sparse   
 \csgraph\_shortest_path.c:14224)
 ImportError: No module named _validation
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 177, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\graphicsItems\ScatterPlotItem.pyc", line 7, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 178, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\widgets\PlotWidget.pyc", line 10, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
 File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 178, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\widgets\GradientWidget.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\GradientEditorItem.pyc", line 8, in <module>
 File "pyqtgraph\colormap.pyc", line 2, in <module>
 File "scipy\interpolate\__init__.pyc", line 160, in <module>
 File "scipy\interpolate\ndgriddata.pyc", line 10, in <module>
 File "scipy\interpolate\interpnd.pyc", line 12, in <module>
 File "scipy\interpolate\interpnd.pyc", line 10, in __load
 File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd (scipy\interpolate\interpnd.c:22803)
 File "scipy\spatial\__init__.pyc", line 87, in <module>
 File "scipy\spatial\kdtree.pyc", line 8, in <module>
 File "scipy\sparse\__init__.pyc", line 193, in <module>
 File "scipy\sparse\csgraph\__init__.pyc", line 148, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 12, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 10, in __load
 File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path (scipy\sparse   
 \csgraph\_shortest_path.c:14224)
 ImportError: No module named _validation
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 178, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\widgets\GraphicsLayoutWidget.pyc", line 2, in <module>
 File "pyqtgraph\graphicsItems\GraphicsLayout.pyc", line 6, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
 File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 178, in <module>
 File "pyqtgraph\__init__.pyc", line 167, in importAll
 File "pyqtgraph\__init__.pyc", line 159, in importModules
 Traceback (most recent call last):
 File "pyqtgraph\__init__.pyc", line 155, in importModules
 File "pyqtgraph\widgets\HistogramLUTWidget.pyc", line 8, in <module>
 File "pyqtgraph\graphicsItems\HistogramLUTItem.pyc", line 10, in <module>
 File "pyqtgraph\graphicsItems\GradientEditorItem.pyc", line 8, in <module>
 File "pyqtgraph\colormap.pyc", line 2, in <module>
 File "scipy\interpolate\__init__.pyc", line 160, in <module>
 File "scipy\interpolate\ndgriddata.pyc", line 10, in <module>
 File "scipy\interpolate\interpnd.pyc", line 12, in <module>
 File "scipy\interpolate\interpnd.pyc", line 10, in __load
 File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd (scipy\interpolate\interpnd.c:22803)
 File "scipy\spatial\__init__.pyc", line 87, in <module>
 File "scipy\spatial\kdtree.pyc", line 8, in <module>
 File "scipy\sparse\__init__.pyc", line 193, in <module>
 File "scipy\sparse\csgraph\__init__.pyc", line 148, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 12, in <module>
 File "scipy\sparse\csgraph\_shortest_path.pyc", line 10, in __load
 File "_shortest_path.pyx", line 18, in init scipy.sparse.csgraph._shortest_path (scipy\sparse   
 \csgraph\_shortest_path.c:14224)
 ImportError: No module named _validation
 Traceback (most recent call last):
 File "pyqtgraph_test.pyw", line 8, in <module>
 File "pyqtgraph\__init__.pyc", line 180, in <module>
 File "pyqtgraph\imageview\__init__.pyc", line 6, in <module>
 File "pyqtgraph\imageview\ImageView.pyc", line 20, in <module>
 File "pyqtgraph\imageview\ImageViewTemplate_pyqt.pyc", line 159, in <module>
 File "pyqtgraph\widgets\PlotWidget.pyc", line 10, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\__init__.pyc", line 1, in <module>
 File "pyqtgraph\graphicsItems\PlotItem\PlotItem.pyc", line 32, in <module>
 File "pyqtgraph\graphicsItems\PlotDataItem.pyc", line 4, in <module>
 File "pyqtgraph\graphicsItems\PlotCurveItem.pyc", line 4, in <module>
 File "scipy\stats\__init__.pyc", line 320, in <module>
 File "scipy\stats\stats.pyc", line 245, in <module>
 ImportError: cannot import name futil

我做错了什么?

【问题讨论】:

您的 scipy 安装似乎有问题:scipy.stats 想要导入不存在的“futil”。你能从交互式会话中导入 scipy.stats 吗? 你是对的。但是在我修复了 scipy 导入后,错误消息保持不变。我按照上述教程的其余部分没有任何改进。错误消息中没有任何变化。教程可能已经过时了吗? 【参考方案1】:

每个版本的 scipy 似乎都有一组不同的错误导致 py2exe 失败。对于最新版本(0.12.0),我发现我的程序中需要这两行,以便 py2exe 将它们包含在构建中:

from scipy.stats import futil
from scipy.sparse.csgraph import _validation

由于某种原因,将这些简单地放在安装脚本中的 py2exe 'includes' 选项中似乎不起作用。

【讨论】:

以上是关于pyqtgraph 编译为可执行文件失败的主要内容,如果未能解决你的问题,请参考以下文章

如何将python脚本编译为二进制可执行文件

CMake 是不是将包含的标头中的所有内容编译到可执行文件中,还是仅将主类中使用的部分编译为可执行文件?

Python 编译为可执行的独立应用程序? [复制]

如何使 clang 编译为 llvm IR

我想将 .py 编译为 .exe

在 Open Suse Leap 15.1 上对 32 位可执行文件的 iconv_open 支持