在parmap上使用pyinstaller会导致tkinter matplotlib导入错误.为什么? [英] Using pyinstaller on parmap causes a tkinter matplotlib import error. Why?

查看:134
本文介绍了在parmap上使用pyinstaller会导致tkinter matplotlib导入错误.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新

如果我尝试从Pyinstaller 3.2降级到3.1,则当我尝试运行可执行文件时得到以下回溯.

If I try downgrading from Pyinstaller 3.2 to 3.1 I instead get the following traceback when I try to run the executable.

我曾尝试将--hidden-import=collect_submodules('pkg_resources._vendor')添加到pyinstaller中,如此处所述,但这没有任何效果.同样的错误.这似乎是由于setuptools的问题.我正在使用26.0.0.许多消息人士称降级到19.3确实可以解决此问题,但是我回到下面的问题.

I tried adding --hidden-import=collect_submodules('pkg_resources._vendor') to pyinstaller as noted here but it had no effect. Same error. This appears to be due to an issue with setuptools. I'm using 26.0.0. Downgrading to 19.3 that many sources say fixes the issue does indeed fix this issue but then I'm back to the issue I have below.

我有一个python 2.7 pyqt4项目,我正在尝试使用pyinstaller将其转换为.exe.我使用:

I have a python 2.7 pyqt4 project I'm trying to turn into an .exe using pyinstaller. I use:

pyinstaller --additional-hooks-rir=. --clean --win-private-assemblies pipegui.py

pipegui.py可以在github 此处找到.

pipegui.py can be found on github here

我得到一个可以运行的可执行文件,并且该应用程序似乎可以运行. 此处是pyinstaller冻结时终端吐出的内容.但是,当我运行程序的特定部分时,应用程序崩溃.它崩溃并且终端进入循环,并在下面不断输出相同的回溯,并在最上方不断增加"Poolworker-X":

I get a working executable and the app appears functional. Here is what the terminal spits while pyinstaller is freezing. However the app crashes when I run particular parts of my program. It crashes and the terminal goes in a loop continually outputting the same traceback below with "Poolworker-X" at the very top continually incrementing:

如您所见,尽管在我的项目中没有出现"tkinter"一词(使用pyqt4),但它暗示了tkinter的存在.我正在使用matplotlib,并且从此处

As you can see tkinter is implicated, despite the word "tkinter" appearing nowhere in my project (using pyqt4). I am making use of matplotlib though and from answers discussed here and here I have added the following to the top of pipegui.py my main script:

    from Tkinter import * 
    import Tkinter
    import FileDialog

但是这似乎是朝错误的方向迈出了一步,因为在冻结后(与以前相同的标志),我的可执行文件甚至都无法打开,而是我得到了:

This however seems to be a step in the wrong direction because after freezing with this (and the same flags as before) my executable wont even open and instead I get this:

此处是pyinstaller冻结时几乎相同的输出.记住我所做的就是在上面添加这3个import语句.就是这样.

Here is pyinstaller's pretty-much identical output while freezeing. Remember all I did was add those 3 import statements above. That's it.

我也尝试了pyinstaller --additional-hooks=. --clean --win-private-assemblies --hidden-import=Tkinter pipegui.py,它没有任何区别.我完全困惑为什么尝试导入tkinter会这样做.解决此追溯问题会使我更接近解决另一个问题吗?

I also tried pyinstaller --additional-hooks=. --clean --win-private-assemblies --hidden-import=Tkinter pipegui.py and it made no difference. I'm completely perplexed as to why trying to import tkinter is doing this. Will fixing this traceback lead me closer to solving the other?

在尝试了所有这些之后,我才发现我的可执行文件崩溃的唯一部分是使用 parmap 多处理.使用matplotlib但不使用parmap的类可以正常工作.

I only figured out after trying all this that the only parts of my executable that are crashing are parts that make use of parmap multiprocessing. Classes that make use of matplotlib but not parmap are working fine.

所以请注意我的问题是如何解决第一个回溯问题,以及为什么尽管我的代码使用niether发生崩溃,但回溯中却同时出现了matplotlib和tkinter?

So please note my question is how the first traceback can be fixed and also why are both matplotlib and tkinter popping up in the traceback despite my code where the crash occurs making use of niether?

额外笔记

  • 根据此处
  • ,我使用--clean --win-private-assemblies修复error code 14001

推荐答案

Repiklis 在评论中提供了解决方案.进一步注意,自2017年1月15日起,Pyinstaller版本3.2.1已发布.我现在使用它,它与 this ,以前我只能通过使用开发人员版本来解决.因此,我强烈建议您升级到最新版本.

Repiklis provided the solution in the comments. Further note that as of January 15 2017 Pyinstaller version 3.2.1 was released. I now use this and it solves this issue along with others like this and this that I could previously only solve by using the developer version. So I highly recommend upgrading to the latest version if you haven't already.

这篇关于在parmap上使用pyinstaller会导致tkinter matplotlib导入错误.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆