Pyqt4-pyqtgraph应用程序以递归方式打开自身的新实例

Fri*_*ter 13 executable pyinstaller pyqt4 python-2.7 pyqtgraph

我为我的项目分叉了BMDanalyse并对其进行了修改.

安装说明,以防您需要帮助.实际问题如下.

由于内存要求,需要64位系统.请确保您拥有64位Python 2.7.

以下设置说明适用于Windows或Ubuntu 上的Pycharm,但您希望在Windows上运行它,因为我的问题是制作.exe:

需要以下包.别忘了选择64位的.在提供链接的情况下,您不能简单地通过Pycharm安装软件包.

打开BMDanalyse项目后,您应该可以运行SPCanalyse.py以启动应用程序.它有bug,是一个非常早期的原型.下载以下示例数据以确保其按预期工作.

如果按顺序执行,以下内容应该有效.您当然可以检查IDE的控制台以了解应用程序正在执行的操作(尚未添加进度条)

  1. 单击文件,加载图像,加载两个图像.点击"对齐".在应用程序执行其操作后,名为的文件aligned.raw应出现在"下载"文件夹中
  2. 加载alignment.raw图像.'alignment.raw'将出现在右侧列表中.单击alignment.raw.单击ROI,添加ROI - >多边形.绘制两个多边形,如下图所示: 在此输入图像描述 获得投资回报率后,单击"分析" - >"投资回报率分析".ROI.raw应该出现在您的下载文件夹中.
  3. 加载ROI.raw.单击它.单击时间过滤器.一段时间后dfoverf0_avg_framesIncl.raw应该出现在您的下载文件夹中
  4. 加载dfoverf0_avg_framesIncl.raw.单击它.屏幕应该变黑.如果它们仍在那里,请删除ROI.现在点击黑色场景中的随机位置.你看到的是种子像素相关图

如果所有这4个步骤都正常工作,那么应用程序就可以按照预期在您的系


实际问题

但是,现在它正在工作,我需要一个独立的.exe这个应用程序,没有任何依赖只是为了向我的主管显示它可以完成.

如果我python SPCanalyse.py在项目中使用我的主脚本,它会运行,我的应用程序会弹出.

更新:我的笔记本电脑被盗了.然而,在一个干净的系统上设置一切我遇到了不同的问题.我能想到的唯一一件不同的主要事情就是我不依赖于Continuum分析中的Anaconda进行包管理.

如果我pyinstaller SPCanalyse.py在我的主脚本上使用,我会得到.exe,如果我运行.exe,我首先注意到我的图标丢失了.其次,这发生了:

在此输入图像描述

当我按下对齐按钮(即通过设置中的步骤1)时,应用程序冻结(即没有响应),然后重复打开自身的新的等级.我假设这是与内存相关的,因为此操作确实需要大量的内存.如果我看一下应用程序占用了多少内存(仅查看原始的"无响应"实例),我每次都看到它的平均值为1,180.8MB.考虑到所有其他正在运行的进程,尽管我仍然只使用了32%内存的28%.我已经尝试将应用程序的优先级设置为高到无效.我也尝试通过命令提示符打开,看看我是否收到任何有用的错误消息.可悲的是没有.

请注意,步骤2-3按预期工作!单击黑色场景后,步骤4将产生相同的递归开放循环.

我想我找到了这里发生的事情的解释:https: //github.com/rdicosmo/parmap

当然,如果您碰巧有开放频道,文件或其他只应由父进程使用的连接,您的程序可能会以非常奇怪的方式运行:例如,在调用之前不要打开图形窗口Parmap原语,如果您的程序是多线程的,请不要使用此库!

因此我很确定我使用parmap非常错误.我仍然困惑为什么我的应用程序工作,如果我通过我的IDE运行我!

旧的未解决的问题,现在是我的小偷的问题

pyinstaller SPCanalyse.py当我尝试运行生成的.exe时,如果我在我的主脚本上使用以下输出

D:\Home\Downloads\BMDanalyse\BMDanalyse>D:\Home\Downloads\BMDanalyse\BMDanalyse\
dist\SPCanalyse\SPCanalyse.exe
Traceback (most recent call last):
  File "<string>", line 21, in <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "BMDanalyse\SPCExplorer\filter_jeff.py", line 9, in <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\image_registration\__init__.py", line 1, in <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\image_registration\cross_correlation_shifts.py", line 4, i
n <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\image_registration\fft_tools\__init__.py", line 3, in <mod
ule>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\image_registration\fft_tools\correlate2d.py", line 2, in <
module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\image_registration\fft_tools\convolve_nd.py", line 329, in
 <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\pytest.py", line 21, in <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\_pytest\config.py", line 11, in <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\_pytest\_code\__init__.py", line 2, in <module>
  File "c:\users\cornelis\appdata\local\temp\pip-build-6xhsyv\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 389, in load_module
  File "site-packages\_pytest\_code\code.py", line 8, in <module>
  File "site-packages\py\_apipkg.py", line 125, in __makeattr
  File "site-packages\py\_apipkg.py", line 48, in importobj
ImportError: No module named _builtin
SPCanalyse returned -1
Run Code Online (Sandbox Code Playgroud)

起初我认为我的问题与没有名为builtins的模块有关,因此我更新了我的setup.py以包含我可以找到的所有可能的包,我的项目远程依赖于:

install_requires = [
    'pyinstaller'
    'future'
    'astropy',
    'image_registration',
    'scipy',
    'FITS_tools',
    'pywcs',
    'pyfits',
    'pytest',
    'parmap',
    'setuptools',
    'pyqtgraph',        
    'matplotlib',
    'numpy',
    'PIL',
    'SPCExplorer',
    ],
Run Code Online (Sandbox Code Playgroud)

我也试过了python setup.py build,我得到了:

D:\Home\Downloads\BMDanalyse>python setup.py build
running build
running build_py
creating build
creating build\lib
creating build\lib\BMDanalyse
copying BMDanalyse\customItems.py -> build\lib\BMDanalyse
copying BMDanalyse\matplotlib_fix.py -> build\lib\BMDanalyse
copying BMDanalyse\ordereddict.py -> build\lib\BMDanalyse
copying BMDanalyse\ROI.py -> build\lib\BMDanalyse
copying BMDanalyse\SidePanel.py -> build\lib\BMDanalyse
copying BMDanalyse\SPCanalyse.py -> build\lib\BMDanalyse
copying BMDanalyse\version.py -> build\lib\BMDanalyse
copying BMDanalyse\ViewBoxCustom.py -> build\lib\BMDanalyse
copying BMDanalyse\__init__.py -> build\lib\BMDanalyse
creating build\lib\BMDanalyse\icons
copying BMDanalyse\icons\arrow-down-2.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\arrow-left.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\arrow-right.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\arrow-up-2.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\filesave.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\file_add.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\file_copy.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\file_delete2.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\green-add3.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\logo.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\opened-folder.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\polygonIcon.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\README.txt -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\rectangularIcon.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\icons\red_delete.png -> build\lib\BMDanalyse\icons
copying BMDanalyse\changeLog.txt -> build\lib\BMDanalyse
creating build\lib\BMDanalyse\sampleMedicalImages
creating build\lib\BMDanalyse\sampleMedicalImages\Implant
creating build\lib\BMDanalyse\sampleMedicalImages\Implant\XYplane
copying BMDanalyse\sampleMedicalImages\Implant\XYplane\vxray_XY_1.png -> build\l
ib\BMDanalyse\sampleMedicalImages\Implant\XYplane
copying BMDanalyse\sampleMedicalImages\Implant\XYplane\vxray_XY_11.png -> build\
lib\BMDanalyse\sampleMedicalImages\Implant\XYplane
copying BMDanalyse\sampleMedicalImages\Implant\XYplane\vxray_XY_21.png -> build\
lib\BMDanalyse\sampleMedicalImages\Implant\XYplane
copying BMDanalyse\sampleMedicalImages\Implant\XYplane\vxray_XY_31.png -> build\
lib\BMDanalyse\sampleMedicalImages\Implant\XYplane
copying BMDanalyse\sampleMedicalImages\Implant\XYplane\vxray_XY_6.png -> build\l
ib\BMDanalyse\sampleMedicalImages\Implant\XYplane
creating build\lib\BMDanalyse\sampleMedicalImages\Implant\YZplane
copying BMDanalyse\sampleMedicalImages\Implant\YZplane\vxray_YZ_1.png -> build\l
ib\BMDanalyse\sampleMedicalImages\Implant\YZplane
copying BMDanalyse\sampleMedicalImages\Implant\YZplane\vxray_YZ_11.png -> build\
lib\BMDanalyse\sampleMedicalImages\Implant\YZplane
copying BMDanalyse\sampleMedicalImages\Implant\YZplane\vxray_YZ_21.png -> build\
lib\BMDanalyse\sampleMedicalImages\Implant\YZplane
copying BMDanalyse\sampleMedicalImages\Implant\YZplane\vxray_YZ_31.png -> build\
lib\BMDanalyse\sampleMedicalImages\Implant\YZplane
copying BMDanalyse\sampleMedicalImages\Implant\YZplane\vxray_YZ_6.png -> build\l
ib\BMDanalyse\sampleMedicalImages\Implant\YZplane
creating build\lib\BMDanalyse\sampleMedicalImages\No implant
creating build\lib\BMDanalyse\sampleMedicalImages\No implant\XYplane
copying BMDanalyse\sampleMedicalImages\No implant\XYplane\noimplant_XY_1.png ->
build\lib\BMDanalyse\sampleMedicalImages\No implant\XYplane
copying BMDanalyse\sampleMedicalImages\No implant\XYplane\noimplant_XY_11.png ->
 build\lib\BMDanalyse\sampleMedicalImages\No implant\XYplane
copying BMDanalyse\sampleMedicalImages\No implant\XYplane\noimplant_XY_21.png ->
 build\lib\BMDanalyse\sampleMedicalImages\No implant\XYplane
copying BMDanalyse\sampleMedicalImages\No implant\XYplane\noimplant_XY_31.png ->
 build\lib\BMDanalyse\sampleMedicalImages\No implant\XYplane
copying BMDanalyse\sampleMedicalImages\No implant\XYplane\noimplant_XY_6.png ->
build\lib\BMDanalyse\sampleMedicalImages\No implant\XYplane
creating build\lib\BMDanalyse\sampleMedicalImages\No implant\YZplane
copying BMDanalyse\sampleMedicalImages\No implant\YZplane\noimplant_YZ_1.png ->
build\lib\BMDanalyse\sampleMedicalImages\No implant\YZplane
copying BMDanalyse\sampleMedicalImages\No implant\YZplane\noimplant_YZ_11.png ->
 build\lib\BMDanalyse\sampleMedicalImages\No implant\YZplane
copying BMDanalyse\sampleMedicalImages\No implant\YZplane\noimplant_YZ_21.png ->
 build\lib\BMDanalyse\sampleMedicalImages\No implant\YZplane
copying BMDanalyse\sampleMedicalImages\No implant\YZplane\noimplant_YZ_31.png ->
 build\lib\BMDanalyse\sampleMedicalImages\No implant\YZplane
copying BMDanalyse\sampleMedicalImages\No implant\YZplane\noimplant_YZ_6.png ->
build\lib\BMDanalyse\sampleMedicalImages\No implant\YZplane
Run Code Online (Sandbox Code Playgroud)

当我去所有这些"构建"的地方时,我看到一个文件夹,其中包含对我的程序绝对必要的脚本.也许这暗示了导致我错误的原因?查看运行build完成的图像(即没有SPCExplorer文件夹):

在此输入图像描述

我不知道这个或者setup.py是否与运行.exe给我错误的原因有什么关系

Fri*_*ter 2

所以问题确实是由于多处理造成的。但是,如果你搜索“multiprocessing pyinstaller”,你可以找到这个

事实证明

只需 在主文件(在我的例子中)multiprocessing.freeze_support()之后添加并在文件开头添加即可。if __name__=='__main__':SPCanalyse.pyimport multiprocessing

我的程序现在作为独立的 .exe 运行并满足列出的所有四个要求