Pyinstaller Syntax error: 'yield' inside async function (Python 3.5.1)

Pyinstaller Syntax error: 'yield' inside async function (Python 3.5.1)

我正在尝试使用 pyinstaller 创建单个可执行文件以分发给未安装 Python 的用户。

该脚本非常简单,只是为了试水,我只使用了几行代码作为 "Guinea Pig"。

Hello World 程序 - 没有导入,转换正常。

导入 matplotlib.pyplot 并绘制值列表的我的豚鼠程序失败了。

这个问题是已知的并记录在案 here,尽管他们声称它已解决,或者我可能无法正确阅读。 我认为修复程序应该在 "dev version" 中可用,它应该是 3.2.1,我已经通过 pip install --upgrade pyinstaller 安装了,但没有用。

我不断收到相同的语法错误,这是在阅读

module jinja2\asyncsupport.py

知道如何解决这个问题吗?我的项目非常简单,只涉及 matplotlibpandas、读取文件和绘制一些数据。

我遇到了同样的错误。

原因是 Jinja2 在 2.9 版本中为 Python3.6 添加了新的异步功能。

请看http://jinja.pocoo.org/docs/2.9/changelog/#version-2-9-6

有两种方法可以避免此错误。 这两个都对我有用。

  1. 降级 jinja2

       # using Anaconda
       conda install jinja2=2.8.1
    
       # using pip
       pip install jinja2==2.8.1
    
  2. 安装 PyInstaller 的开发版本

      # install from github
      # Don't run "pip install -U pyinstaller" because the dev version is not released yet
      pip install git+https://github.com/pyinstaller/pyinstaller.git
    
      # check if "PyInstaller (3.3.dev0+g483dfde)" is in the list
      pip list