【问题标题】:Python - library loading from different projectPython - 从不同项目加载库
【发布时间】:2020-11-23 08:32:59
【问题描述】:

亲爱的 Stack 社区,您好,

我坚持将我的 Python 项目导出到可执行文件。我在 Windows 10、Python 3.8 上使用 PyCharm。我检查了 Project Interpreter - 它正在从正确的项目加载 Python.exe。 我的项目从 IDE 启动后运行良好,但是当我通过命令导出时:

pyinstaller --onefile Gui.py -n Foo

运行 Foo.exe 时出现错误,如附加的屏幕截图所示。问题是 Python 从其他位置,从其他项目中寻找库 openpyxl。我在 ...venv/Lib/site-packages 中检查了我的项目(Gui.py 所在的位置),它就在那里。但我不能让我的 .exe 工作。如何让它从正确的项目加载库?还是有其他问题?

帮助我 StackOverflow 社区,你是我唯一的希望。

【问题讨论】:

    标签: python python-3.x modulenotfounderror


    【解决方案1】:

    使用命令pyinstaller --onefile (filename) --hidden-import (the python file you want to import on the main file) -n (name you want)导出

    【讨论】:

      猜你喜欢
      • 2011-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多