gpt4 book ai didi

Python:Sqlalchemy 搞砸了 pyinstaller?

转载 作者:行者123 更新时间:2023-12-02 17:44:30 24 4
gpt4 key购买 nike

我正在尝试使用 pyinstaller 打包我的程序。该代码在 Windows 上运行良好,并使用 SqlAlchemy、OpenCV 和 pyodbc 包。

我运行 pyinstaller 来创建可执行文件并尝试运行它。我收到一个错误:

ImportError: No module named ConfigParser

现在,我重新运行了同样的事情并查看了 pyinstaller 的日志并收到了警告:
WARNING: Hidden import "sqlalchemy.sql.functions.func" not found!

和其他几个人一起。
然后有一个关于尝试以小写和大写形式导入 ConfigParser 的警告。
 Attempted to add Python module twice with different upper/lowercases: ConfigParser

这里可能是什么问题?

最佳答案

所以,我想通了。在一定程度上。
似乎 pyInstaller 不能很好地处理 SWIG 文件。

sqlalchemy.utils有一个名为 compat.py 的文件.它可以使模块与所有版本的 python 兼容。

例如,在 python2.x 中,有 ConfigParser而在 py3 中,它被命名为 configparser所以compat.py中有一个部分来处理它:

if py3:
import configparser
# Some other such import statements
elif py2:
import ConfigParser as configparser

现在,pyinstaller 在这里被难住了,因为它只专注于导入,因此它尝试同时导入两者并且惨遭失败。
我对此的粗略解决方法涉及修改 compat.py 文件并仅保留与我拥有的 python 版本(2.x)相关的部分。
再次运行 pyinstaller 证明是成功的! :)

尽管这一切都非常粗糙并且可能有更好的东西,但我找不到任何东西,所以我分享了对我有用的东西。

关于Python:Sqlalchemy 搞砸了 pyinstaller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38263837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com