通过 pyinstaller 在捆绑的应用程序中包含 smartsheet sdk

问题描述 投票:0回答:2

我使用 smartsheet SDK 开发了一个 Python 2.7 应用程序,它在你的机器上运行良好。然后我通过 PyInstaller 将它捆绑到一个应用程序中,当我运行它时出现这个错误:

DEBUG:smartsheet.smartsheet:try loading api class Home
DEBUG:smartsheet.smartsheet:try loading model class Home
DEBUG:smartsheet.smartsheet:ImportError! Cound not load api or model
      class Home Exception in Tkinter callback Traceback (most recent call
      last):   File "lib-tk/Tkinter.py", line 1536, in __call__   File
      "pacers.py", line 166, in log_processing   File "pacers.py", line 57,
      in new_sheet AttributeError: 'str' object has no attribute
      'create_sheet'

编辑1:

就是这个AttributeError让我摸不着头脑。我可以在此之前毫无问题地创建其他智能表对象。并且运行源代码不会出现问题。有什么想法吗?

它从源头上工作得很好! -->

DEBUG:smartsheet.smartsheet:try loading api class Home
DEBUG:smartsheet.smartsheet:loaded instance of api class Home
DEBUG:smartsheet.models.column:deleting index from obj (filter: create_sheet)
DEBUG:smartsheet.models.column:deleting locked from obj (filter: create_sheet)

编辑2:

原来 PyInstaller 没有正确导入所有模块,必须显式导入对象,例如smartsheet.主页

python api pyinstaller smartsheet-api
2个回答
1
投票

我有类似的问题,

为了解决我用

from smartsheet import Smartsheet
代替
import smartsheet


0
投票

上面的编辑 #2 是为我解决这个问题的关键,但语法不清楚。

我原来的进口声明是:

from smartsheet import Smartsheet
。使用此导入语句,我可以毫无问题地从 .py 文件运行我的代码。

为了让我的代码从 pyinstaller 创建的 .exe 文件运行,我不得不将我的导入语句更改为:

from smartsheet import Smartsheet, home, folders, sheets
。 (区分大小写)

(我的代码引用了 Home、Folder 和 Sheet 对象。)

© www.soinside.com 2019 - 2024. All rights reserved.