NSIS:无法导入修补程序

时间:2019-04-12 16:26:53

标签: python windows matplotlib pynsist

我想构建使用matplotlib的程序,该程序需要tkinter。 问题是我不能包含tkinter,因为它不在pyPi上(并且现在有轮子)。

我使用Pynsist构建NSIS安装程序。这是cfg:

[Application]
name=SineWave
version=1.0
# How to launch the app - this calls the 'main' function from the 'myapp' package:
entry_point=main:main
icon=sinewave.ico

[Python]
version=3.6.5

[Include]
# Packages from PyPI that your application requires, one per line
# These must have wheels on PyPI:
pypi_wheels = numpy==1.16.1
    matplotlib==3.0.3
    pyparsing==2.4.0
    cycler==0.10.0
    six==1.11.0
    python-dateutil==2.8.0
    kiwisolver==1.0.1
    anaconda-project==0.8.2

如果我运行生成的exe,它将返回以下内容:

Traceback (most recent call last):
  File "C:\Users\Novot\AppData\Local\SineWave\SineWave.launch.pyw", line 31, in <module>
    from main import main
  File "C:\Users\Novot\AppData\Local\SineWave\pkgs\main.py", line 2, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\Novot\AppData\Local\SineWave\pkgs\matplotlib\pyplot.py", line 2372, in <module>
    switch_backend(rcParams["backend"])
  File "C:\Users\Novot\AppData\Local\SineWave\pkgs\matplotlib\pyplot.py", line 207, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "importlib\__init__.py", line 126, in import_module
  File "C:\Users\Novot\AppData\Local\SineWave\pkgs\matplotlib\backends\backend_tkagg.py", line 1, in <module>
    from . import _backend_tk
  File "C:\Users\Novot\AppData\Local\SineWave\pkgs\matplotlib\backends\_backend_tk.py", line 5, in <module>
    import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'

而且,有没有一种方法可以导入另一个库所需的所有库?

1 个答案:

答案 0 :(得分:0)

我在文档中找到它: Pynsist documentation

“由于Pynsist使用了Python的“捆绑”版本,因此默认情况下不包含tkinter模块。如果您的应用程序依赖tkinter来创建GUI,那么您需要查找以下资产...”