python - PyInstaller 不导入队列

标签 python pyinstaller

我正在尝试使用 twisted 和 Queue 编译一些脚本。

pyinstaller sample.py --onefile
# -*- coding: utf-8 -*-#
from twisted import *
import queue as Queue
a = Queue.Queue()

不幸的是,生成的文件失败并显示 ImportError: No module named queue

最佳答案

我认为这根本不是 PyInstaller 或 Twisted 相关的问题。 Queue 模块是标准库的一部分,问题在于您如何命名它。在 Python 2 中,它是带有大写字母的 Queue,但在 Python 3 中,它被重命名为 queue 以遵循更标准的命名约定,其中模块名称为小写。

您的脚本似乎是 Python 2 代码到 Python 3 的端口(因此 importas Queue 部分),但您正在使用 Python 运行它2还是。这可能会以其他更微妙的方式失败,而不仅仅是 Queue 导入错误(例如,它的 Unicode 处理可能完全错误)。

关于python - PyInstaller 不导入队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36400111/

相关文章:

java - 有什么方法可以获取 Java 代码块而不是整个类的 AST(抽象语法树)?

python - Pyinstaller Jinja2 TemplateNotFound

python - 运行 .exe 文件 Python 2.7 时 Pyinstaller Intel MKL fatal error

python - 使用pyinstaller时如何从pyqt5库中排除opengl32sw.dll?

python - 高低: Computer guesses your number

python - 将 URL 路径拆分为组件

python - 目录路径python中的空格

python - Pyinstaller,名称错误 : global name 'quit' is not defined

python - 运行 pyinstaller 应用程序时导入错误

python - 使用 Python lfilter 过滤信号